Skip to contentSkip to conversation

Enable / require DEVRES for devm_.alloc usage outside xPL

PATCH Superseded Tom Rini 6 participants 28 messages Dec 19, 2025 – Jan 16

Subsystems (31)
Network drivers Arm (32-bit) x86 USB +27 more subsystems
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

cover Enable / require DEVRES for devm_.alloc usage outside xPL

Hey all,

As seen by a number of patches fixing memory leaks, U-Boot has a problem with developer expectations around devm_kmalloc and friends. Namely, whereas in Linux these memory allocations will be freed automatically in most cases, in U-Boot this is only true if DEVRES is enabled. Now, intentionally, in xPL phases, we do not (and do not offer as an option) enabling DEVRES. However in full U-Boot this is left either to the user, or some drivers have select'd DEVRES on their own. This inconsistency is a problem. This series goes and deals with two small issues that were shown by having all drivers that use devm_.alloc to allocate memory also select DEVRES and then we make DEVRES no longer be a prompted option and instead select'd as needed. We do not make this unconditional as it would result in growing the resulting binary on the many platforms which have no users of the devm_.alloc family of functions.

Signature · 1 line
Tom
author
#1 lore raw

PATCH 1/3 mips: Reduce size in gardena-smart-gateway-mt7688

This platform is near the binary size limit for U-Boot. Disable booting some unlikely OS options in order to reclaim some space.

---
Cc: Stefan Roese <[email protected]>

---
 configs/gardena-smart-gateway-mt7688_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
configs/gardena-smart-gateway-mt7688_defconfig +4 -0
index 3c2bcc6a3c44..3bfb004cf2b3 100644
@@ -48,6 +48,10 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_NOR_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_LICENSE=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
 # CONFIG_CMD_ELF is not set
 # CONFIG_CMD_XIMG is not set
 CONFIG_CMD_MEMINFO=y
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] mips: Reduce size in gardena-smart-gateway-mt7688

Quoted 6 lines · Tom Rini

This platform is near the binary size limit for U-Boot. Disable booting some unlikely OS options in order to reclaim some space.

---
Cc: Stefan Roese <[email protected]>

Thanks,
Stefan

Quoted 19 lines
---
  configs/gardena-smart-gateway-mt7688_defconfig | 4 ++++
  1 file changed, 4 insertions(+)
configs/gardena-smart-gateway-mt7688_defconfig +4 -0
index 3c2bcc6a3c44..3bfb004cf2b3 100644
@@ -48,6 +48,10 @@ CONFIG_SPL_SYS_MALLOC_SIMPLE=y
  CONFIG_SPL_NOR_SUPPORT=y
  CONFIG_HUSH_PARSER=y
  CONFIG_CMD_LICENSE=y
+# CONFIG_BOOTM_NETBSD is not set
+# CONFIG_BOOTM_PLAN9 is not set
+# CONFIG_BOOTM_RTEMS is not set
+# CONFIG_BOOTM_VXWORKS is not set
  # CONFIG_CMD_ELF is not set
  # CONFIG_CMD_XIMG is not set
  CONFIG_CMD_MEMINFO=y
author
#3 lore raw

PATCH 2/3 x86: Increase SYS_MALLOC_F_LEN to 0x1000

In reply to Tom Rini

A few x86 platforms use a SYS_MALLOC_F_LEN value of 0x1000 or higher. With the impending move to having DEVRES enabled by default, we will need a little more room here. Raise the default value.

---
Cc: Bin Meng <[email protected]>

---
 Kconfig                    | 4 ++--
 arch/x86/Kconfig           | 3 ---
 configs/qemu-x86_defconfig | 1 -
 3 files changed, 2 insertions(+), 6 deletions(-)
Kconfig +2 -2
index 1d6003426855..aef7aa2c841d 100644
@@ -299,8 +299,8 @@ config SYS_MALLOC_F_LEN
 			 ROCKCHIP_RV1108
 	default 0x600 if ARCH_ZYNQMP_R5 || ARCH_ZYNQMP
 	default 0x800 if ARCH_ZYNQ || ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
-			 ROCKCHIP_RK322X || X86
-	default 0x1000 if ARCH_MESON || ARCH_BMIPS || ARCH_MTMIPS
+			 ROCKCHIP_RK322X
+	default 0x1000 if ARCH_MESON || ARCH_BMIPS || ARCH_MTMIPS || X86
 	default 0x1800 if ARCH_TEGRA
 	default 0x4000 if SANDBOX || RISCV || ARCH_APPLE || ROCKCHIP_RK3368 || \
 			  ROCKCHIP_RK3399
arch/x86/Kconfig +0 -3
index 5aa134b6bcbe..48b033e7e27c 100644
@@ -133,9 +133,6 @@ source "arch/x86/cpu/tangier/Kconfig"
 config AHCI
 	default y
 
-config SYS_MALLOC_F_LEN
-	default 0x800
-
 config RAMBASE
 	hex
 	default 0x100000
configs/qemu-x86_defconfig +0 -1
index a3210bc4a5ce..6bea902c947a 100644
@@ -1,6 +1,5 @@
 CONFIG_X86=y
 CONFIG_TEXT_BASE=0xFFF00000
-CONFIG_SYS_MALLOC_F_LEN=0x1000
 CONFIG_BLOBLIST_SIZE_RELOC=0x40000
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x40000
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] x86: Increase SYS_MALLOC_F_LEN to 0x1000

Quoted 5 lines · Tom Rini

A few x86 platforms use a SYS_MALLOC_F_LEN value of 0x1000 or higher. With the impending move to having DEVRES enabled by default, we will need a little more room here. Raise the default value.

Quoted 9 lines

---
Cc: Bin Meng <[email protected]>

---
 Kconfig                    | 4 ++--
 arch/x86/Kconfig           | 3 ---
 configs/qemu-x86_defconfig | 1 -
 3 files changed, 2 insertions(+), 6 deletions(-)
author
#5 lore raw

PATCH 3/3 dm: core: Default to using DEVRES outside of xPL

In reply to Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

---
 arch/arm/mach-stm32mp/Kconfig    | 1 +
 drivers/block/Kconfig            | 1 +
 drivers/clk/Kconfig              | 1 +
 drivers/core/Kconfig             | 7 ++++---
 drivers/dma/ti/Kconfig           | 1 +
 drivers/firmware/Kconfig         | 1 +
 drivers/firmware/arm-ffa/Kconfig | 1 +
 drivers/gpio/Kconfig             | 3 +++
 drivers/i2c/muxes/Kconfig        | 1 +
 drivers/i3c/Kconfig              | 1 +
 drivers/mailbox/Kconfig          | 1 +
 drivers/mtd/nand/raw/Kconfig     | 5 +++++
 drivers/mtd/nand/spi/Kconfig     | 1 +
 drivers/mtd/spi/Kconfig          | 1 +
 drivers/mux/Kconfig              | 1 +
 drivers/net/Kconfig              | 3 +++
 drivers/net/phy/Kconfig          | 2 ++
 drivers/pci/Kconfig              | 3 +++
 drivers/phy/Kconfig              | 1 +
 drivers/pinctrl/Kconfig          | 1 +
 drivers/pinctrl/mscc/Kconfig     | 1 +
 drivers/pinctrl/mvebu/Kconfig    | 1 +
 drivers/pinctrl/renesas/Kconfig  | 1 +
 drivers/power/regulator/Kconfig  | 1 +
 drivers/reboot-mode/Kconfig      | 1 +
 drivers/reset/Kconfig            | 1 +
 drivers/smem/Kconfig             | 1 +
 drivers/soc/ti/Kconfig           | 1 +
 drivers/spi/Kconfig              | 2 ++
 drivers/usb/cdns3/Kconfig        | 1 +
 drivers/usb/dwc3/Kconfig         | 1 +
 drivers/usb/host/Kconfig         | 1 +
 drivers/video/Kconfig            | 1 +
 include/dm/devres.h              | 3 ++-
 34 files changed, 50 insertions(+), 4 deletions(-)
arch/arm/mach-stm32mp/Kconfig +1 -0
index ba4694f29644..2716844b2599 100644
@@ -170,6 +170,7 @@ config STM32_ECDSA_VERIFY
 
 config STM32MP_TAMP_NVMEM
 	bool "STM32 TAMP backup registers via NVMEM API"
+	select DEVRES
 	select NVMEM
 	default y
 	help
drivers/block/Kconfig +1 -0
index 185da2b5cfc2..461b5a9fc838 100644
@@ -265,6 +265,7 @@ config SYS_64BIT_LBA
 
 config RKMTD
 	bool "Rockchip rkmtd virtual block device"
+	select DEVRES
 	select RANDOM_UUID
 	help
 	  Enable "rkmtd" class and driver to create a virtual block device
drivers/clk/Kconfig +1 -0
index 85cc472b4cb9..ae783254008c 100644
@@ -3,6 +3,7 @@ menu "Clock"
 config CLK
 	bool "Enable clock driver support"
 	depends on DM
+	select DEVRES
 	help
 	  This allows drivers to be provided for clock generators, including
 	  oscillators and PLLs. Devices can use a common clock API to request
drivers/core/Kconfig +4 -3
index 6b4330fe4ea3..53eaa2da25b9 100644
@@ -197,6 +197,7 @@ config DM_DMA
 config REGMAP
 	bool "Support register maps"
 	depends on DM
+	select DEVRES
 	help
 	  Hardware peripherals tend to have one or more sets of registers
 	  which can be accessed to control the hardware. A register map
@@ -271,7 +272,7 @@ config VPL_SYSCON
 	  assigning a unique number to each.
 
 config DEVRES
-	bool "Managed device resources"
+	bool
 	depends on DM
 	help
 	  This option enables the Managed device resources core support.
@@ -279,8 +280,8 @@ config DEVRES
 	  released whether initialization fails half-way or the device gets
 	  detached.
 
-	  If this option is disabled, devres functions fall back to
-	  non-managed variants.  For example, devres_alloc() to kzalloc(),
+	  This option is disabled in xPL phases anddevres functions fall back
+	  to non-managed variants.  For example, devres_alloc() to kzalloc(),
 	  devm_kmalloc() to kmalloc(), etc.
 
 config DEBUG_DEVRES
drivers/dma/ti/Kconfig +1 -0
index 87c026e04903..5cec6ddd3e30 100644
@@ -5,6 +5,7 @@ if ARCH_K3
 config TI_K3_NAVSS_UDMA
         bool "Texas Instruments UDMA"
         depends on ARCH_K3
+        select DEVRES
         select DMA
         select TI_K3_NAVSS_RINGACC
         select TI_K3_NAVSS_PSILCFG
drivers/firmware/Kconfig +1 -0
index a094e6c3afef..220de7319506 100644
@@ -16,6 +16,7 @@ config ARM_PSCI_FW
 config TI_SCI_PROTOCOL
 	tristate "TI System Control Interface (TISCI) Message Protocol"
 	depends on K3_SEC_PROXY
+	select DEVRES
 	select FIRMWARE
 	select SPL_FIRMWARE if SPL
 	help
drivers/firmware/arm-ffa/Kconfig +1 -0
index d75f8b53fd85..3706a8893059 100644
@@ -6,6 +6,7 @@ config ARM_FFA_TRANSPORT
 	select ARM_SMCCC if !SANDBOX
 	select ARM_SMCCC_FEATURES if !SANDBOX
 	imply CMD_ARMFFA
+	select DEVRES
 	select LIB_UUID
 	select DEVRES
 	help
drivers/gpio/Kconfig +3 -0
index 18ca8ad4caca..60c5c54688e6 100644
@@ -19,6 +19,7 @@ if GPIO
 config DM_GPIO
 	bool "Enable Driver Model for GPIO drivers"
 	depends on DM
+	select DEVRES
 	help
 	  Enable driver model for GPIO access. The standard GPIO
 	  interface (gpio_get_value(), etc.) is then implemented by
@@ -151,6 +152,7 @@ config CORTINA_GPIO
 config DWAPB_GPIO
 	bool "DWAPB GPIO driver"
 	depends on DM && DM_GPIO
+	select DEVRES
 	help
 	  Support for the Designware APB GPIO driver.
 
@@ -253,6 +255,7 @@ config IMX_RGPIO2P
 
 config IPROC_GPIO
 	bool "Broadcom iProc GPIO driver(without pinconf)"
+	select DEVRES
 	help
 	  The Broadcom iProc based SoCs- Cygnus, NS2, NS3, NSP and Stingray,
 	  use the same GPIO Controller IP hence this driver could be used
drivers/i2c/muxes/Kconfig +1 -0
index 65319bb6fd83..3b1220b21056 100644
@@ -51,6 +51,7 @@ config I2C_MUX_PCA954x
 config I2C_MUX_GPIO
         tristate "GPIO-based I2C multiplexer"
 	depends on I2C_MUX && DM_GPIO
+	select DEVRES
 	help
 	  If you say yes to this option, support will be included for
 	  a GPIO based I2C multiplexer. This driver provides access to
drivers/i3c/Kconfig +1 -0
index d877a7443538..48341f9b8737 100644
@@ -1,6 +1,7 @@
 menuconfig I3C
 	tristate "I3C support"
 	select I2C
+	select DEVRES
 	help
 	  I3C is a serial protocol standardized by the MIPI alliance.
 
drivers/mailbox/Kconfig +1 -0
index cfd2a3be3fd0..f45e611c9662 100644
@@ -31,6 +31,7 @@ config IMX_MU_MBOX
 config MPFS_MBOX
 	bool "Enable MPFS system controller support"
 	depends on DM_MAILBOX && ARCH_RV64I
+	select DEVRES
 	help
 	  Enable support for the mailboxes that provide a communication
 	  channel with the system controller integrated on PolarFire SoC.
drivers/mtd/nand/raw/Kconfig +5 -0
index 5e4d1c0a9378..e0ff28cb21bd 100644
@@ -51,6 +51,7 @@ config DM_NAND_ATMEL
 	bool "Support Atmel NAND controller with DM support"
 	depends on ARCH_AT91
 	select ATMEL_EBI
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	imply SYS_NAND_USE_FLASH_BBT
 	help
@@ -74,6 +75,7 @@ config ATMEL_NAND_HWECC
 config ATMEL_NAND_HW_PMECC
 	bool "Atmel Programmable Multibit ECC (PMECC)"
 	select ATMEL_NAND_HWECC
+	select DEVRES
 	help
 	  The Programmable Multibit ECC (PMECC) controller is a programmable
 	  binary BCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder.
@@ -118,6 +120,7 @@ config NAND_BRCMNAND
 	bool "Support Broadcom NAND controller"
 	depends on OF_CONTROL && DM && DM_MTD
 	depends on ARCH_BCMBCA || ARCH_BMIPS || TARGET_BCMNS || TARGET_BCMNS3
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	help
 	  Enable the driver for NAND flash on platforms using a Broadcom NAND
@@ -197,6 +200,7 @@ config SPL_NAND_LOAD
 config NAND_CADENCE
 	bool "Support Cadence NAND controller as a DT device"
 	depends on OF_CONTROL && DM_MTD && ARCH_SOCFPGA
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	select SPL_SYS_NAND_SELF_INIT
 	select SPL_NAND_BASE
@@ -211,6 +215,7 @@ config NAND_CADENCE
 
 config NAND_DENALI
 	bool
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	select SYS_NAND_ONFI_DETECTION if TARGET_SOCFPGA_SOC64
 	imply CMD_NAND
drivers/mtd/nand/spi/Kconfig +1 -0
index 0777dfdf0a70..1124dada9506 100644
@@ -1,6 +1,7 @@
 menuconfig MTD_SPI_NAND
 	bool "SPI NAND device Support"
 	depends on DM_MTD && DM_SPI
+	select DEVRES
 	select MTD_NAND_CORE
 	select SPI_MEM
 	help
drivers/mtd/spi/Kconfig +1 -0
index ca60a425ba34..a13c7fc60e68 100644
@@ -3,6 +3,7 @@ menu "SPI Flash Support"
 config DM_SPI_FLASH
 	bool "Enable Driver Model for SPI flash"
 	depends on DM_SPI
+	select DEVRES
 	imply SPI_FLASH
 	help
 	  Enable driver model for SPI flash. This SPI flash interface
drivers/mux/Kconfig +1 -0
index 2b95eb02177c..de74e5d5e4ed 100644
@@ -3,6 +3,7 @@ menu "Multiplexer drivers"
 config MULTIPLEXER
 	bool "Multiplexer Support"
 	depends on DM
+	select DEVRES
 	help
 	 The mux framework is a minimalistic subsystem that handles multiplexer
 	 controllers. It provides the same API as Linux and mux drivers should
drivers/net/Kconfig +3 -0
index f382a7752d53..13e631c55dc2 100644
@@ -125,6 +125,7 @@ config AIROHA_ETH
 	bool "Airoha Ethernet QDMA Driver"
 	depends on ARCH_AIROHA
 	select PHYLIB
+	select DEVRES
 	select DM_RESET
 	select MDIO_MT7531
 	help
@@ -359,6 +360,7 @@ config ETH_SANDBOX_RAW
 
 config ETH_DESIGNWARE
 	bool "Synopsys Designware Ethernet MAC"
+	select DEVRES
 	select PHYLIB
 	imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA
 	help
@@ -555,6 +557,7 @@ config MVNETA
 config MVPP2
 	bool "Marvell Armada 375/7K/8K network interface support"
 	depends on ARMADA_375 || ARMADA_8K
+	select DEVRES
 	select PHYLIB
 	select MVMDIO
 	select DM_MDIO
drivers/net/phy/Kconfig +2 -0
index d0aab0b8fe87..709f1c91eb2d 100644
@@ -182,6 +182,7 @@ config PHY_MARVELL
 
 config PHY_MARVELL_10G
 	bool "Marvell Alaska 10Gbit PHYs"
+	select DEVRES
 	help
 	  Support for the Marvell Alaska MV88X3310 and compatible PHYs.
 
@@ -245,6 +246,7 @@ config PHY_NATSEMI
 
 config PHY_NXP_C45_TJA11XX
 	tristate "NXP C45 TJA11XX PHYs"
+	select DEVRES
 	help
 	  Enable support for NXP C45 TJA11XX PHYs.
 	  Currently supports only the TJA1103 PHY.
drivers/pci/Kconfig +3 -0
index ea9868425d04..8fc57895a786 100644
@@ -131,6 +131,7 @@ config PCIE_APPLE
 	bool "Enable Apple PCIe driver"
 	depends on ARCH_APPLE
 	imply PCI_INIT_R
+	select DEVRES
 	select SYS_PCI_64BIT
 	default y
 	help
@@ -264,6 +265,7 @@ config PCI_XILINX
 
 config PCIE_LAYERSCAPE
 	bool
+	select DEVRES
 
 config PCIE_LAYERSCAPE_RC
 	bool "Layerscape PCIe Root Complex mode support"
@@ -361,6 +363,7 @@ config PCI_KEYSTONE
 config PCIE_MEDIATEK
 	bool "MediaTek PCIe Gen2 controller"
 	depends on ARCH_MEDIATEK
+	select DEVRES
 	help
 	  Say Y here if you want to enable Gen2 PCIe controller,
 	  which could be found on MT7623 SoC family.
drivers/phy/Kconfig +1 -0
index 420d7c7a44dd..87729b479bd9 100644
@@ -4,6 +4,7 @@ menu "PHY Subsystem"
 config PHY
 	bool "PHY Core"
 	depends on DM
+	select DEVRES
 	help
 	  PHY support.
 
drivers/pinctrl/Kconfig +1 -0
index 48119694031d..ea90713ec6ca 100644
@@ -294,6 +294,7 @@ config PINCTRL_SANDBOX
 config PINCTRL_SINGLE
 	bool "Single register pin-control and pin-multiplex driver"
 	depends on DM
+	select DEVRES
 	help
 	  This enables pinctrl driver for systems using a single register for
 	  pin configuration and multiplexing. TI's AM335X SoCs are examples of
drivers/pinctrl/mscc/Kconfig +1 -0
index aab67fabd2cd..567c93f404cc 100644
@@ -2,6 +2,7 @@
 
 config PINCTRL_MSCC
 	bool
+	select DEVRES
 
 config PINCTRL_MSCC_OCELOT
 	depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
drivers/pinctrl/mvebu/Kconfig +1 -0
index 7c51d138c8bd..10ba440f246e 100644
@@ -9,6 +9,7 @@ config PINCTRL_ARMADA_38X
 
 config PINCTRL_ARMADA_37XX
 	depends on ARMADA_3700 && PINCTRL_FULL
+	select DEVRES
 	bool "Armada 37xx pin control driver"
 	help
 	   Support pin multiplexing and pin configuration control on
drivers/pinctrl/renesas/Kconfig +1 -0
index ac40b31dbfaa..171da88cfcf4 100644
@@ -166,6 +166,7 @@ config PINCTRL_RZG2L
 	depends on PINCTRL
 	depends on PINCTRL_GENERIC
 	depends on PINCONF
+	select DEVRES
 	help
 	  Support the pinctrl functionality of the pin function controller (PFC)
 	  on the Renesas RZ/G2L SoC family.
drivers/power/regulator/Kconfig +1 -0
index 1875e61967c0..a9c82d6d24c2 100644
@@ -235,6 +235,7 @@ config DM_REGULATOR_GPIO
 config DM_REGULATOR_QCOM_RPMH
 	bool "Enable driver model for Qualcomm RPMh regulator"
 	depends on DM_REGULATOR && QCOM_RPMH
+	select DEVRES
 	---help---
 	  Enable support for the Qualcomm RPMh regulator. The driver
 	  implements get/set api for a limited set of regulators used
drivers/reboot-mode/Kconfig +1 -0
index bb5189351881..72b33d712235 100644
@@ -9,6 +9,7 @@ menu "Reboot Mode Support"
 config DM_REBOOT_MODE
 	bool "Enable reboot mode using Driver Model"
 	depends on DM
+	select DEVRES
 	help
 		Enable support for reboot mode control. This will allow users to
 		adjust the boot process based on reboot mode parameter
drivers/reset/Kconfig +1 -0
index 74c267dfc4e5..2fd91d6299cc 100644
@@ -3,6 +3,7 @@ menu "Reset Controller Support"
 config DM_RESET
 	bool "Enable reset controllers using Driver Model"
 	depends on DM && OF_CONTROL
+	select DEVRES
 	help
 	  Enable support for the reset controller driver class. Many hardware
 	  modules are equipped with a reset signal, typically driven by some
drivers/smem/Kconfig +1 -0
index 73d51b3a7a48..e5d7dcc81b17 100644
@@ -16,6 +16,7 @@ config MSM_SMEM
     bool "Qualcomm Shared Memory Manager (SMEM)"
     depends on DM
     depends on ARCH_SNAPDRAGON || ARCH_IPQ40XX
+    select DEVRES
     help
       Enable support for the Qualcomm Shared Memory Manager.
       The driver provides an interface to items in a heap shared among all
drivers/soc/ti/Kconfig +1 -0
index 0ee21f990488..36129cb72f68 100644
@@ -8,6 +8,7 @@ if SOC_TI
 config TI_K3_NAVSS_RINGACC
 	bool "K3 Ring accelerator Sub System"
 	depends on ARCH_K3
+	select DEVRES
 	select MISC
 	help
 	  Say y here to support the K3 AM65x Ring accelerator module.
drivers/spi/Kconfig +2 -0
index e31db9d4e31b..50d22bf3fc4c 100644
@@ -35,6 +35,7 @@ config DM_SPI
 
 config SPI_MEM
 	bool "SPI memory extension"
+	select DEVRES
 	help
 	  Enable this option if you want to enable the SPI memory extension.
 	  This extension is meant to simplify interaction with SPI memories
@@ -343,6 +344,7 @@ config MT7621_SPI
 config MTK_SNOR
 	bool "Mediatek SPI-NOR controller driver"
 	depends on SPI_MEM
+	select DEVRES
 	help
 	  Enable the Mediatek SPINOR controller driver. This driver has
           better read/write performance with NOR.
drivers/usb/cdns3/Kconfig +1 -0
index 1d5e4afac6cd..7964f3f41d5e 100644
@@ -1,6 +1,7 @@
 config USB_CDNS3
 	tristate "Cadence USB3 Dual-Role Controller"
 	depends on USB_XHCI_HCD || USB_GADGET
+	select DEVRES
 	help
 	  Say Y here if your system has a Cadence USB3 dual-role controller.
 	  It supports: Host-only, and Peripheral-only.
drivers/usb/dwc3/Kconfig +1 -0
index 744dfa90463c..27fcae54b227 100644
@@ -1,6 +1,7 @@
 config USB_DWC3
 	bool "DesignWare USB3 DRD Core Support"
 	depends on USB_XHCI_HCD || USB_GADGET
+	select DEVRES
 	help
 	  Say Y here if your system has a Dual Role SuperSpeed
 	  USB controller based on the DesignWare USB3 IP Core.
drivers/usb/host/Kconfig +1 -0
index 99f381db9f9b..54df4264a441 100644
@@ -367,6 +367,7 @@ config USB_OHCI_GENERIC
 config USB_OHCI_DA8XX
 	bool "Support for da850 OHCI USB controller"
 	depends on ARCH_DAVINCI
+	select DEVRES
 	help
 	  Enable support for the da850 USB controller.
 
drivers/video/Kconfig +1 -0
index b5777da5218a..2c67d089492c 100644
@@ -831,6 +831,7 @@ config BACKLIGHT_LM3533
 config BACKLIGHT_LP855x
 	bool "Backlight Driver for LP855x"
 	depends on BACKLIGHT
+	select DEVRES
 	select DM_I2C
 	help
 	  Say Y to enable the backlight driver for National Semiconductor / TI
include/dm/devres.h +2 -1
index 27761deb6d1f..406d18686f4d 100644
@@ -207,7 +207,8 @@ void devm_kfree(struct udevice *dev, void *ptr);
 /* Get basic stats on allocations */
 void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);
 
-#else /* ! DEVRES */
+#elif IS_ENABLED(CONFIG_DEVRES) && defined(CONFIG_XPL_BUILD)
+/* Allow these to be dummy functions in xPL builds. */
 
 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {
Signature · 1 line
2.43.0
#6 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Hi Tom,

Quoted 8 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

Quoted 4 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

Most of the time boards don't enable DM_DEVICE_REMOVE to save code size. We certainly don't unbind devices. A memory leak implies some sort of problem, but if we are booting the OS, all the memory is 'freed' by that process.

What problem are you solving here? It is missing from your commit.

Regards,
Simon

author
#7 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Quoted 11 lines · Simon Glass

Hi Tom,

Quoted 8 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

Quoted 6 lines
Quoted 3 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

Most of the time boards don't enable DM_DEVICE_REMOVE to save code size.

I'm not talking about DM_DEVICE_REMOVE anywhere in this series.

Quoted 5 lines

We certainly don't unbind devices. A memory leak implies some sort of problem, but if we are booting the OS, all the memory is 'freed' by that process.

What problem are you solving here? It is missing from your commit.

The problem being solved is stated in the commit message.

Signature · 1 line
Tom
#8 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Hi Tom,

Quoted 13 lines · Tom Rini
Quoted 11 lines · Simon Glass

Hi Tom,

Quoted 8 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

Most of the time boards don't enable DM_DEVICE_REMOVE to save code size.

I'm not talking about DM_DEVICE_REMOVE anywhere in this series.

Without that, devres_release_all() is never called. How are you expecting things to be freed?

Quoted 8 lines
Quoted 6 lines

We certainly don't unbind devices. A memory leak implies some sort of problem, but if we are booting the OS, all the memory is 'freed' by that process.

What problem are you solving here? It is missing from your commit.

The problem being solved is stated in the commit message.

Can you elaborate a bit? I see a vague reference to memory leaks, but you should explain the problem. Are you trying to free memory before booting an OS? Are you worried about devices being repeatedly probed and removed, thus causing a memory leak within U-Boot? It's just too unclear.

Depending on what you are trying to achieve, we should perhaps make DEVRES depend on DM_DEVICE_REMOVE

Regards,
Simon

author
#9 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Quoted 37 lines · Simon Glass

Hi Tom,

Quoted 13 lines · Tom Rini
Quoted 11 lines · Simon Glass

Hi Tom,

Quoted 8 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

Most of the time boards don't enable DM_DEVICE_REMOVE to save code size.

I'm not talking about DM_DEVICE_REMOVE anywhere in this series.

Without that, devres_release_all() is never called. How are you expecting things to be freed?

Quoted 8 lines
Quoted 6 lines

We certainly don't unbind devices. A memory leak implies some sort of problem, but if we are booting the OS, all the memory is 'freed' by that process.

What problem are you solving here? It is missing from your commit.

The problem being solved is stated in the commit message.

Quoted 8 lines

Can you elaborate a bit? I see a vague reference to memory leaks, but you should explain the problem. Are you trying to free memory before booting an OS? Are you worried about devices being repeatedly probed and removed, thus causing a memory leak within U-Boot? It's just too unclear.

Depending on what you are trying to achieve, we should perhaps make DEVRES depend on DM_DEVICE_REMOVE

I'm not sure why you're talking about what you're talking about, sorry. The problem being solved is very plainly stated in the commit message, which in sum is that we violate expectations on how these functions normally work, and should stop doing that so that in turn people stop posting driver-specific fixes.

Signature · 1 line
Tom
#10 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

In reply to Tom Rini

Hi Tom

Quoted 108 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

---
 arch/arm/mach-stm32mp/Kconfig    | 1 +
 drivers/block/Kconfig            | 1 +
 drivers/clk/Kconfig              | 1 +
 drivers/core/Kconfig             | 7 ++++---
 drivers/dma/ti/Kconfig           | 1 +
 drivers/firmware/Kconfig         | 1 +
 drivers/firmware/arm-ffa/Kconfig | 1 +
 drivers/gpio/Kconfig             | 3 +++
 drivers/i2c/muxes/Kconfig        | 1 +
 drivers/i3c/Kconfig              | 1 +
 drivers/mailbox/Kconfig          | 1 +
 drivers/mtd/nand/raw/Kconfig     | 5 +++++
 drivers/mtd/nand/spi/Kconfig     | 1 +
 drivers/mtd/spi/Kconfig          | 1 +
 drivers/mux/Kconfig              | 1 +
 drivers/net/Kconfig              | 3 +++
 drivers/net/phy/Kconfig          | 2 ++
 drivers/pci/Kconfig              | 3 +++
 drivers/phy/Kconfig              | 1 +
 drivers/pinctrl/Kconfig          | 1 +
 drivers/pinctrl/mscc/Kconfig     | 1 +
 drivers/pinctrl/mvebu/Kconfig    | 1 +
 drivers/pinctrl/renesas/Kconfig  | 1 +
 drivers/power/regulator/Kconfig  | 1 +
 drivers/reboot-mode/Kconfig      | 1 +
 drivers/reset/Kconfig            | 1 +
 drivers/smem/Kconfig             | 1 +
 drivers/soc/ti/Kconfig           | 1 +
 drivers/spi/Kconfig              | 2 ++
 drivers/usb/cdns3/Kconfig        | 1 +
 drivers/usb/dwc3/Kconfig         | 1 +
 drivers/usb/host/Kconfig         | 1 +
 drivers/video/Kconfig            | 1 +
 include/dm/devres.h              | 3 ++-
 34 files changed, 50 insertions(+), 4 deletions(-)
arch/arm/mach-stm32mp/Kconfig +1 -0
index ba4694f29644..2716844b2599 100644
@@ -170,6 +170,7 @@ config STM32_ECDSA_VERIFY
 
 config STM32MP_TAMP_NVMEM
        bool "STM32 TAMP backup registers via NVMEM API"
+       select DEVRES
        select NVMEM
        default y
        help
drivers/block/Kconfig +1 -0
index 185da2b5cfc2..461b5a9fc838 100644
@@ -265,6 +265,7 @@ config SYS_64BIT_LBA
 
 config RKMTD
        bool "Rockchip rkmtd virtual block device"
+       select DEVRES
        select RANDOM_UUID
        help
          Enable "rkmtd" class and driver to create a virtual block device
drivers/clk/Kconfig +1 -0
index 85cc472b4cb9..ae783254008c 100644
@@ -3,6 +3,7 @@ menu "Clock"
 config CLK
        bool "Enable clock driver support"
        depends on DM
+       select DEVRES
        help
          This allows drivers to be provided for clock generators, including
          oscillators and PLLs. Devices can use a common clock API to request
drivers/core/Kconfig +2 -1
index 6b4330fe4ea3..53eaa2da25b9 100644
@@ -197,6 +197,7 @@ config DM_DMA
 config REGMAP
        bool "Support register maps"
        depends on DM
+       select DEVRES
        help
          Hardware peripherals tend to have one or more sets of registers
          which can be accessed to control the hardware. A register map
@@ -271,7 +272,7 @@ config VPL_SYSCON
          assigning a unique number to each.
 
 config DEVRES
-       bool "Managed device resources"
+       bool
        depends on DM
        help
          This option enables the Managed device resources core support.

drivers/core/Kconfig config DEVRES · line 283

Quoted 6 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

Quoted 453 lines
drivers/core/Kconfig +1 -0
+         to non-managed variants.  For example, devres_alloc() to kzalloc(),
          devm_kmalloc() to kmalloc(), etc.
 
 config DEBUG_DEVRES
drivers/dma/ti/Kconfig +1 -0
index 87c026e04903..5cec6ddd3e30 100644
@@ -5,6 +5,7 @@ if ARCH_K3
 config TI_K3_NAVSS_UDMA
         bool "Texas Instruments UDMA"
         depends on ARCH_K3
+        select DEVRES
         select DMA
         select TI_K3_NAVSS_RINGACC
         select TI_K3_NAVSS_PSILCFG
drivers/firmware/Kconfig +1 -0
index a094e6c3afef..220de7319506 100644
@@ -16,6 +16,7 @@ config ARM_PSCI_FW
 config TI_SCI_PROTOCOL
        tristate "TI System Control Interface (TISCI) Message Protocol"
        depends on K3_SEC_PROXY
+       select DEVRES
        select FIRMWARE
        select SPL_FIRMWARE if SPL
        help
drivers/firmware/arm-ffa/Kconfig +1 -0
index d75f8b53fd85..3706a8893059 100644
@@ -6,6 +6,7 @@ config ARM_FFA_TRANSPORT
        select ARM_SMCCC if !SANDBOX
        select ARM_SMCCC_FEATURES if !SANDBOX
        imply CMD_ARMFFA
+       select DEVRES
        select LIB_UUID
        select DEVRES
        help
drivers/gpio/Kconfig +3 -0
index 18ca8ad4caca..60c5c54688e6 100644
@@ -19,6 +19,7 @@ if GPIO
 config DM_GPIO
        bool "Enable Driver Model for GPIO drivers"
        depends on DM
+       select DEVRES
        help
          Enable driver model for GPIO access. The standard GPIO
          interface (gpio_get_value(), etc.) is then implemented by
@@ -151,6 +152,7 @@ config CORTINA_GPIO
 config DWAPB_GPIO
        bool "DWAPB GPIO driver"
        depends on DM && DM_GPIO
+       select DEVRES
        help
          Support for the Designware APB GPIO driver.
 
@@ -253,6 +255,7 @@ config IMX_RGPIO2P
 
 config IPROC_GPIO
        bool "Broadcom iProc GPIO driver(without pinconf)"
+       select DEVRES
        help
          The Broadcom iProc based SoCs- Cygnus, NS2, NS3, NSP and Stingray,
          use the same GPIO Controller IP hence this driver could be used
drivers/i2c/muxes/Kconfig +1 -0
index 65319bb6fd83..3b1220b21056 100644
@@ -51,6 +51,7 @@ config I2C_MUX_PCA954x
 config I2C_MUX_GPIO
         tristate "GPIO-based I2C multiplexer"
        depends on I2C_MUX && DM_GPIO
+       select DEVRES
        help
          If you say yes to this option, support will be included for
          a GPIO based I2C multiplexer. This driver provides access to
drivers/i3c/Kconfig +1 -0
index d877a7443538..48341f9b8737 100644
@@ -1,6 +1,7 @@
 menuconfig I3C
        tristate "I3C support"
        select I2C
+       select DEVRES
        help
          I3C is a serial protocol standardized by the MIPI alliance.
 
drivers/mailbox/Kconfig +1 -0
index cfd2a3be3fd0..f45e611c9662 100644
@@ -31,6 +31,7 @@ config IMX_MU_MBOX
 config MPFS_MBOX
        bool "Enable MPFS system controller support"
        depends on DM_MAILBOX && ARCH_RV64I
+       select DEVRES
        help
          Enable support for the mailboxes that provide a communication
          channel with the system controller integrated on PolarFire SoC.
drivers/mtd/nand/raw/Kconfig +5 -0
index 5e4d1c0a9378..e0ff28cb21bd 100644
@@ -51,6 +51,7 @@ config DM_NAND_ATMEL
        bool "Support Atmel NAND controller with DM support"
        depends on ARCH_AT91
        select ATMEL_EBI
+       select DEVRES
        select SYS_NAND_SELF_INIT
        imply SYS_NAND_USE_FLASH_BBT
        help
@@ -74,6 +75,7 @@ config ATMEL_NAND_HWECC
 config ATMEL_NAND_HW_PMECC
        bool "Atmel Programmable Multibit ECC (PMECC)"
        select ATMEL_NAND_HWECC
+       select DEVRES
        help
          The Programmable Multibit ECC (PMECC) controller is a programmable
          binary BCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder.
@@ -118,6 +120,7 @@ config NAND_BRCMNAND
        bool "Support Broadcom NAND controller"
        depends on OF_CONTROL && DM && DM_MTD
        depends on ARCH_BCMBCA || ARCH_BMIPS || TARGET_BCMNS || TARGET_BCMNS3
+       select DEVRES
        select SYS_NAND_SELF_INIT
        help
          Enable the driver for NAND flash on platforms using a Broadcom NAND
@@ -197,6 +200,7 @@ config SPL_NAND_LOAD
 config NAND_CADENCE
        bool "Support Cadence NAND controller as a DT device"
        depends on OF_CONTROL && DM_MTD && ARCH_SOCFPGA
+       select DEVRES
        select SYS_NAND_SELF_INIT
        select SPL_SYS_NAND_SELF_INIT
        select SPL_NAND_BASE
@@ -211,6 +215,7 @@ config NAND_CADENCE
 
 config NAND_DENALI
        bool
+       select DEVRES
        select SYS_NAND_SELF_INIT
        select SYS_NAND_ONFI_DETECTION if TARGET_SOCFPGA_SOC64
        imply CMD_NAND
drivers/mtd/nand/spi/Kconfig +1 -0
index 0777dfdf0a70..1124dada9506 100644
@@ -1,6 +1,7 @@
 menuconfig MTD_SPI_NAND
        bool "SPI NAND device Support"
        depends on DM_MTD && DM_SPI
+       select DEVRES
        select MTD_NAND_CORE
        select SPI_MEM
        help
drivers/mtd/spi/Kconfig +1 -0
index ca60a425ba34..a13c7fc60e68 100644
@@ -3,6 +3,7 @@ menu "SPI Flash Support"
 config DM_SPI_FLASH
        bool "Enable Driver Model for SPI flash"
        depends on DM_SPI
+       select DEVRES
        imply SPI_FLASH
        help
          Enable driver model for SPI flash. This SPI flash interface
drivers/mux/Kconfig +1 -0
index 2b95eb02177c..de74e5d5e4ed 100644
@@ -3,6 +3,7 @@ menu "Multiplexer drivers"
 config MULTIPLEXER
        bool "Multiplexer Support"
        depends on DM
+       select DEVRES
        help
         The mux framework is a minimalistic subsystem that handles multiplexer
         controllers. It provides the same API as Linux and mux drivers should
drivers/net/Kconfig +3 -0
index f382a7752d53..13e631c55dc2 100644
@@ -125,6 +125,7 @@ config AIROHA_ETH
        bool "Airoha Ethernet QDMA Driver"
        depends on ARCH_AIROHA
        select PHYLIB
+       select DEVRES
        select DM_RESET
        select MDIO_MT7531
        help
@@ -359,6 +360,7 @@ config ETH_SANDBOX_RAW
 
 config ETH_DESIGNWARE
        bool "Synopsys Designware Ethernet MAC"
+       select DEVRES
        select PHYLIB
        imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA
        help
@@ -555,6 +557,7 @@ config MVNETA
 config MVPP2
        bool "Marvell Armada 375/7K/8K network interface support"
        depends on ARMADA_375 || ARMADA_8K
+       select DEVRES
        select PHYLIB
        select MVMDIO
        select DM_MDIO
drivers/net/phy/Kconfig +2 -0
index d0aab0b8fe87..709f1c91eb2d 100644
@@ -182,6 +182,7 @@ config PHY_MARVELL
 
 config PHY_MARVELL_10G
        bool "Marvell Alaska 10Gbit PHYs"
+       select DEVRES
        help
          Support for the Marvell Alaska MV88X3310 and compatible PHYs.
 
@@ -245,6 +246,7 @@ config PHY_NATSEMI
 
 config PHY_NXP_C45_TJA11XX
        tristate "NXP C45 TJA11XX PHYs"
+       select DEVRES
        help
          Enable support for NXP C45 TJA11XX PHYs.
          Currently supports only the TJA1103 PHY.
drivers/pci/Kconfig +3 -0
index ea9868425d04..8fc57895a786 100644
@@ -131,6 +131,7 @@ config PCIE_APPLE
        bool "Enable Apple PCIe driver"
        depends on ARCH_APPLE
        imply PCI_INIT_R
+       select DEVRES
        select SYS_PCI_64BIT
        default y
        help
@@ -264,6 +265,7 @@ config PCI_XILINX
 
 config PCIE_LAYERSCAPE
        bool
+       select DEVRES
 
 config PCIE_LAYERSCAPE_RC
        bool "Layerscape PCIe Root Complex mode support"
@@ -361,6 +363,7 @@ config PCI_KEYSTONE
 config PCIE_MEDIATEK
        bool "MediaTek PCIe Gen2 controller"
        depends on ARCH_MEDIATEK
+       select DEVRES
        help
          Say Y here if you want to enable Gen2 PCIe controller,
          which could be found on MT7623 SoC family.
drivers/phy/Kconfig +1 -0
index 420d7c7a44dd..87729b479bd9 100644
@@ -4,6 +4,7 @@ menu "PHY Subsystem"
 config PHY
        bool "PHY Core"
        depends on DM
+       select DEVRES
        help
          PHY support.
 
drivers/pinctrl/Kconfig +1 -0
index 48119694031d..ea90713ec6ca 100644
@@ -294,6 +294,7 @@ config PINCTRL_SANDBOX
 config PINCTRL_SINGLE
        bool "Single register pin-control and pin-multiplex driver"
        depends on DM
+       select DEVRES
        help
          This enables pinctrl driver for systems using a single register for
          pin configuration and multiplexing. TI's AM335X SoCs are examples of
drivers/pinctrl/mscc/Kconfig +1 -0
index aab67fabd2cd..567c93f404cc 100644
@@ -2,6 +2,7 @@
 
 config PINCTRL_MSCC
        bool
+       select DEVRES
 
 config PINCTRL_MSCC_OCELOT
        depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
drivers/pinctrl/mvebu/Kconfig +1 -0
index 7c51d138c8bd..10ba440f246e 100644
@@ -9,6 +9,7 @@ config PINCTRL_ARMADA_38X
 
 config PINCTRL_ARMADA_37XX
        depends on ARMADA_3700 && PINCTRL_FULL
+       select DEVRES
        bool "Armada 37xx pin control driver"
        help
           Support pin multiplexing and pin configuration control on
drivers/pinctrl/renesas/Kconfig +1 -0
index ac40b31dbfaa..171da88cfcf4 100644
@@ -166,6 +166,7 @@ config PINCTRL_RZG2L
        depends on PINCTRL
        depends on PINCTRL_GENERIC
        depends on PINCONF
+       select DEVRES
        help
          Support the pinctrl functionality of the pin function controller (PFC)
          on the Renesas RZ/G2L SoC family.
drivers/power/regulator/Kconfig +1 -0
index 1875e61967c0..a9c82d6d24c2 100644
@@ -235,6 +235,7 @@ config DM_REGULATOR_GPIO
 config DM_REGULATOR_QCOM_RPMH
        bool "Enable driver model for Qualcomm RPMh regulator"
        depends on DM_REGULATOR && QCOM_RPMH
+       select DEVRES
        ---help---
          Enable support for the Qualcomm RPMh regulator. The driver
          implements get/set api for a limited set of regulators used
drivers/reboot-mode/Kconfig +1 -0
index bb5189351881..72b33d712235 100644
@@ -9,6 +9,7 @@ menu "Reboot Mode Support"
 config DM_REBOOT_MODE
        bool "Enable reboot mode using Driver Model"
        depends on DM
+       select DEVRES
        help
                Enable support for reboot mode control. This will allow users to
                adjust the boot process based on reboot mode parameter
drivers/reset/Kconfig +1 -0
index 74c267dfc4e5..2fd91d6299cc 100644
@@ -3,6 +3,7 @@ menu "Reset Controller Support"
 config DM_RESET
        bool "Enable reset controllers using Driver Model"
        depends on DM && OF_CONTROL
+       select DEVRES
        help
          Enable support for the reset controller driver class. Many hardware
          modules are equipped with a reset signal, typically driven by some
drivers/smem/Kconfig +1 -0
index 73d51b3a7a48..e5d7dcc81b17 100644
@@ -16,6 +16,7 @@ config MSM_SMEM
     bool "Qualcomm Shared Memory Manager (SMEM)"
     depends on DM
     depends on ARCH_SNAPDRAGON || ARCH_IPQ40XX
+    select DEVRES
     help
       Enable support for the Qualcomm Shared Memory Manager.
       The driver provides an interface to items in a heap shared among all
drivers/soc/ti/Kconfig +1 -0
index 0ee21f990488..36129cb72f68 100644
@@ -8,6 +8,7 @@ if SOC_TI
 config TI_K3_NAVSS_RINGACC
        bool "K3 Ring accelerator Sub System"
        depends on ARCH_K3
+       select DEVRES
        select MISC
        help
          Say y here to support the K3 AM65x Ring accelerator module.
drivers/spi/Kconfig +2 -0
index e31db9d4e31b..50d22bf3fc4c 100644
@@ -35,6 +35,7 @@ config DM_SPI
 
 config SPI_MEM
        bool "SPI memory extension"
+       select DEVRES
        help
          Enable this option if you want to enable the SPI memory extension.
          This extension is meant to simplify interaction with SPI memories
@@ -343,6 +344,7 @@ config MT7621_SPI
 config MTK_SNOR
        bool "Mediatek SPI-NOR controller driver"
        depends on SPI_MEM
+       select DEVRES
        help
          Enable the Mediatek SPINOR controller driver. This driver has
           better read/write performance with NOR.
drivers/usb/cdns3/Kconfig +1 -0
index 1d5e4afac6cd..7964f3f41d5e 100644
@@ -1,6 +1,7 @@
 config USB_CDNS3
        tristate "Cadence USB3 Dual-Role Controller"
        depends on USB_XHCI_HCD || USB_GADGET
+       select DEVRES
        help
          Say Y here if your system has a Cadence USB3 dual-role controller.
          It supports: Host-only, and Peripheral-only.
drivers/usb/dwc3/Kconfig +1 -0
index 744dfa90463c..27fcae54b227 100644
@@ -1,6 +1,7 @@
 config USB_DWC3
        bool "DesignWare USB3 DRD Core Support"
        depends on USB_XHCI_HCD || USB_GADGET
+       select DEVRES
        help
          Say Y here if your system has a Dual Role SuperSpeed
          USB controller based on the DesignWare USB3 IP Core.
drivers/usb/host/Kconfig +1 -0
index 99f381db9f9b..54df4264a441 100644
@@ -367,6 +367,7 @@ config USB_OHCI_GENERIC
 config USB_OHCI_DA8XX
        bool "Support for da850 OHCI USB controller"
        depends on ARCH_DAVINCI
+       select DEVRES
        help
          Enable support for the da850 USB controller.
 
drivers/video/Kconfig +1 -0
index b5777da5218a..2c67d089492c 100644
@@ -831,6 +831,7 @@ config BACKLIGHT_LM3533
 config BACKLIGHT_LP855x
        bool "Backlight Driver for LP855x"
        depends on BACKLIGHT
+       select DEVRES
        select DM_I2C
        help
          Say Y to enable the backlight driver for National Semiconductor / TI
include/dm/devres.h +0 -0
index 27761deb6d1f..406d18686f4d 100644

include/dm/devres.h void devm_kfree(struct udevice *dev, void *ptr); · line 214

Quoted 9 lines
include/dm/devres.h +2 -1
@@ -207,7 +207,8 @@ void devm_kfree(struct udevice *dev, void *ptr);
 /* Get basic stats on allocations */
 void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);
 
-#else /* ! DEVRES */
+#elif IS_ENABLED(CONFIG_DEVRES) && defined(CONFIG_XPL_BUILD)
+/* Allow these to be dummy functions in xPL builds. */
 
 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Michael

Quoted 3 lines

--
2.43.0

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
author
#11 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Quoted 14 lines · Michael Nazzareno Trimarchi

Hi Tom

Quoted 11 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

[snip]

Quoted 9 lines

drivers/core/Kconfig config DEVRES · line 283

Quoted 7 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

OK.

[snip]

Quoted 5 lines

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Sure. So for example:
commit 00e1fed93c8c3e4c9037741ea1b70a9e693a6e65

Author: Francois Berder <[email protected]>
Date:   Tue Nov 11 11:30:19 2025 +0100

firmware: ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource

- Fix temp memory leak
- Free memory during error handling

Is needed (I'd have to re-read the threads to see if in whole or in part) because DEVRES is optional today. And barring drivers/core/devres.c doesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, and devm_kfree these devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches adding devm_kfree() calls to devm_kmalloc()'d areas.

Signature · 1 line
Tom
#12 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Hi

Quoted 48 lines · Tom Rini
Quoted 14 lines · Michael Nazzareno Trimarchi

Hi Tom

Quoted 11 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

[snip]

Quoted 9 lines

drivers/core/Kconfig config DEVRES · line 283

Quoted 7 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

OK.

[snip]

Quoted 5 lines

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Sure. So for example:
commit 00e1fed93c8c3e4c9037741ea1b70a9e693a6e65

Author: Francois Berder <[email protected]>
Date:   Tue Nov 11 11:30:19 2025 +0100

firmware: ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource

- Fix temp memory leak
- Free memory during error handling

Quoted 7 lines

Is needed (I'd have to re-read the threads to see if in whole or in part) because DEVRES is optional today. And barring drivers/core/devres.c doesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, and devm_kfree these devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches adding devm_kfree() calls to devm_kmalloc()'d areas.

As far as I understand the devres_release_probe should then free the resources allocated to dm_device.

Michael

Quoted 3 lines

--
Tom

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
author
#13 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Quoted 59 lines · Michael Nazzareno Trimarchi

Hi

Quoted 48 lines · Tom Rini
Quoted 14 lines · Michael Nazzareno Trimarchi

Hi Tom

Quoted 11 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

[snip]

Quoted 9 lines

drivers/core/Kconfig config DEVRES · line 283

Quoted 7 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

OK.

[snip]

Quoted 5 lines

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Sure. So for example:
commit 00e1fed93c8c3e4c9037741ea1b70a9e693a6e65

Author: Francois Berder <[email protected]>
Date:   Tue Nov 11 11:30:19 2025 +0100

firmware: ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource

- Fix temp memory leak
- Free memory during error handling

Quoted 7 lines

Is needed (I'd have to re-read the threads to see if in whole or in part) because DEVRES is optional today. And barring drivers/core/devres.c doesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, and devm_kfree these devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches adding devm_kfree() calls to devm_kmalloc()'d areas.

Quoted 2 lines

As far as I understand the devres_release_probe should then free the resources allocated to dm_device.

Right. And without DEVRES enabled we don't have this match between alloc and free, which is unexpected by most users of devm_kmalloc/etc as that path is not optional in the kernel.

Signature · 1 line
Tom
#14 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

Hi

Quoted 61 lines · Tom Rini
Quoted 59 lines · Michael Nazzareno Trimarchi

Hi

Quoted 55 lines · Tom Rini
Quoted 14 lines · Michael Nazzareno Trimarchi

Hi Tom

Quoted 11 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

[snip]

Quoted 9 lines

drivers/core/Kconfig config DEVRES · line 283

Quoted 7 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

OK.

[snip]

Quoted 5 lines

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Sure. So for example:
commit 00e1fed93c8c3e4c9037741ea1b70a9e693a6e65

Author: Francois Berder <[email protected]>
Date:   Tue Nov 11 11:30:19 2025 +0100

firmware: ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource

- Fix temp memory leak
- Free memory during error handling

Is needed (I'd have to re-read the threads to see if in whole or in part) because DEVRES is optional today. And barring drivers/core/devres.c doesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, and devm_kfree these devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches adding devm_kfree() calls to devm_kmalloc()'d areas.

Quoted 7 lines
Quoted 2 lines

As far as I understand the devres_release_probe should then free the resources allocated to dm_device.

Right. And without DEVRES enabled we don't have this match between alloc and free, which is unexpected by most users of devm_kmalloc/etc as that path is not optional in the kernel.

Please add in your commit, including the typo

Quoted 2 lines

--
Tom

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#15 lore raw

Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL

In reply to Tom Rini
Quoted 48 lines · Tom Rini
Quoted 14 lines · Michael Nazzareno Trimarchi

Hi Tom

Quoted 11 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks. Rather than manually tracking allocations and implementing frees, rework things so that we follow expectations now and enable the DEVRES functionality to manage frees.

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

[snip]

Quoted 9 lines

drivers/core/Kconfig config DEVRES · line 283

Quoted 7 lines
drivers/core/Kconfig +1 -2
@@ -279,8 +280,8 @@ config DEVRES
          released whether initialization fails half-way or the device gets
          detached.
 
-         If this option is disabled, devres functions fall back to
-         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases anddevres functions fall back

Fix this typo

OK.

[snip]

Quoted 5 lines

Can you please in the commit message a concrete example on what this commit takes care of?
In short expand here:
" in full U-Boot, the corresponding automatic free. This in turn leads to memory leaks."

Sure. So for example:
commit 00e1fed93c8c3e4c9037741ea1b70a9e693a6e65

Author: Francois Berder <[email protected]>
Date:   Tue Nov 11 11:30:19 2025 +0100

firmware: ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource

- Fix temp memory leak
- Free memory during error handling

Quoted 7 lines

Is needed (I'd have to re-read the threads to see if in whole or in part) because DEVRES is optional today. And barring drivers/core/devres.c doesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, and devm_kfree these devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches adding devm_kfree() calls to devm_kmalloc()'d areas.

OK we seem to have got there now.

From my reading of that commit, the author does not understand what devres is. The same code in Linux would be just as odd.

So I suggest expanding the help for 'config DEVRES' as well.

Regards,
Simom

author
#16 lore raw

Re: (subset) [PATCH 0/3] Enable / require DEVRES for devm_.alloc usage outside xPL

In reply to Tom Rini
Quoted 16 lines · Tom Rini

Hey all,

As seen by a number of patches fixing memory leaks, U-Boot has a problem with developer expectations around devm_kmalloc and friends. Namely, whereas in Linux these memory allocations will be freed automatically in most cases, in U-Boot this is only true if DEVRES is enabled. Now, intentionally, in xPL phases, we do not (and do not offer as an option) enabling DEVRES. However in full U-Boot this is left either to the user, or some drivers have select'd DEVRES on their own. This inconsistency is a problem. This series goes and deals with two small issues that were shown by having all drivers that use devm_.alloc to allocate memory also select DEVRES and then we make DEVRES no longer be a prompted option and instead select'd as needed. We do not make this unconditional as it would result in growing the resulting binary on the many platforms which have no users of the devm_.alloc family of functions.

Quoted 1 line

[...]

Applied to u-boot/next, thanks!

[1/3] mips: Reduce size in gardena-smart-gateway-mt7688

      commit: 22ef38f6933adfa0d89b6841f4671f6595f967d5
Signature · 1 line
Tom
author
#17 lore raw

v2 cover Enable / require DEVRES for devm_.alloc usage outside xPL

In reply to Tom Rini

Hey all,

As seen by a number of patches fixing memory leaks, U-Boot has a problem with developer expectations around devm_kmalloc and friends. Namely, whereas in Linux these memory allocations will be freed automatically in most cases, in U-Boot this is only true if DEVRES is enabled. Now, intentionally, in xPL phases, we do not (and do not offer as an option) enabling DEVRES. However in full U-Boot this is left either to the user, or some drivers have select'd DEVRES on their own. This inconsistency is a problem. This series goes and deals with two small issues that were shown by having all drivers that use devm_.alloc to allocate memory also select DEVRES and then we make DEVRES no longer be a prompted option and instead select'd as needed. We do not make this unconditional as it would result in growing the resulting binary on the many platforms which have no users of the devm_.alloc family of functions.

Changes in v2:
- Patch 1/3 has been merged for other reasons
- Patch 2/3 has Bin's tag now
- Patch 3/3 has a reworded commit message to try and be clearer about the problem, fixed a typo spotted by Michael and adds his tag.

Signature · 1 line
Tom
author
#18 lore raw

PATCH v2 1/2 x86: Increase SYS_MALLOC_F_LEN to 0x1000

A few x86 platforms use a SYS_MALLOC_F_LEN value of 0x1000 or higher. With the impending move to having DEVRES enabled by default, we will need a little more room here. Raise the default value.

---
Changes in v2:
- Pickup Bin's tag

---
 Kconfig                    | 4 ++--
 arch/x86/Kconfig           | 3 ---
 configs/qemu-x86_defconfig | 1 -
 3 files changed, 2 insertions(+), 6 deletions(-)
Kconfig +2 -2
index c435fb431826..ce25ea24a60f 100644
@@ -299,8 +299,8 @@ config SYS_MALLOC_F_LEN
 			 ROCKCHIP_RV1108
 	default 0x600 if ARCH_ZYNQMP_R5 || ARCH_ZYNQMP
 	default 0x800 if ARCH_ZYNQ || ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
-			 ROCKCHIP_RK322X || X86
-	default 0x1000 if ARCH_MESON || ARCH_BMIPS || ARCH_MTMIPS
+			 ROCKCHIP_RK322X
+	default 0x1000 if ARCH_MESON || ARCH_BMIPS || ARCH_MTMIPS || X86
 	default 0x1800 if ARCH_TEGRA
 	default 0x4000 if SANDBOX || RISCV || ARCH_APPLE || ROCKCHIP_RK3368 || \
 			  ROCKCHIP_RK3399
arch/x86/Kconfig +0 -3
index 5aa134b6bcbe..48b033e7e27c 100644
@@ -133,9 +133,6 @@ source "arch/x86/cpu/tangier/Kconfig"
 config AHCI
 	default y
 
-config SYS_MALLOC_F_LEN
-	default 0x800
-
 config RAMBASE
 	hex
 	default 0x100000
configs/qemu-x86_defconfig +0 -1
index a3210bc4a5ce..6bea902c947a 100644
@@ -1,6 +1,5 @@
 CONFIG_X86=y
 CONFIG_TEXT_BASE=0xFFF00000
-CONFIG_SYS_MALLOC_F_LEN=0x1000
 CONFIG_BLOBLIST_SIZE_RELOC=0x40000
 CONFIG_NR_DRAM_BANKS=8
 CONFIG_ENV_SIZE=0x40000
Signature · 1 line
2.43.0
author
#19 lore raw

PATCH v2 2/2 dm: core: Default to using DEVRES outside of xPL

In reply to Tom Rini

The devm alloc functions that we have may follow the Linux kernel model where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the tracking and free()'ing functionality. This in turn leads to memory leaks because the driver author expects that since the functions have the same name as in the Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations by enabling the DEVRES functionality (outside of xPL phases).

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

---
Changes in v2:
- Fix typo that Michael spotted
- Reword the commit message to try and be clearer about the problem today.
- Add Michael's tag.
- Expand the help text around DEVRES slightly to include mentioning devm_kmalloc and family and that it should work like in the Linux Kernel.

---
 arch/arm/mach-stm32mp/Kconfig    |  1 +
 drivers/block/Kconfig            |  1 +
 drivers/clk/Kconfig              |  1 +
 drivers/core/Kconfig             | 10 ++++++----
 drivers/dma/ti/Kconfig           |  1 +
 drivers/firmware/Kconfig         |  1 +
 drivers/firmware/arm-ffa/Kconfig |  1 +
 drivers/gpio/Kconfig             |  3 +++
 drivers/i2c/muxes/Kconfig        |  1 +
 drivers/i3c/Kconfig              |  1 +
 drivers/mailbox/Kconfig          |  1 +
 drivers/mtd/nand/raw/Kconfig     |  5 +++++
 drivers/mtd/nand/spi/Kconfig     |  1 +
 drivers/mtd/spi/Kconfig          |  1 +
 drivers/mux/Kconfig              |  1 +
 drivers/net/Kconfig              |  3 +++
 drivers/net/phy/Kconfig          |  2 ++
 drivers/pci/Kconfig              |  3 +++
 drivers/phy/Kconfig              |  1 +
 drivers/pinctrl/Kconfig          |  1 +
 drivers/pinctrl/mscc/Kconfig     |  1 +
 drivers/pinctrl/mvebu/Kconfig    |  1 +
 drivers/pinctrl/renesas/Kconfig  |  1 +
 drivers/power/regulator/Kconfig  |  1 +
 drivers/reboot-mode/Kconfig      |  1 +
 drivers/reset/Kconfig            |  1 +
 drivers/smem/Kconfig             |  1 +
 drivers/soc/ti/Kconfig           |  1 +
 drivers/spi/Kconfig              |  2 ++
 drivers/usb/cdns3/Kconfig        |  1 +
 drivers/usb/dwc3/Kconfig         |  1 +
 drivers/usb/host/Kconfig         |  1 +
 drivers/video/Kconfig            |  1 +
 include/dm/devres.h              |  3 ++-
 34 files changed, 52 insertions(+), 5 deletions(-)
arch/arm/mach-stm32mp/Kconfig +1 -0
index ba4694f29644..2716844b2599 100644
@@ -170,6 +170,7 @@ config STM32_ECDSA_VERIFY
 
 config STM32MP_TAMP_NVMEM
 	bool "STM32 TAMP backup registers via NVMEM API"
+	select DEVRES
 	select NVMEM
 	default y
 	help
drivers/block/Kconfig +1 -0
index 185da2b5cfc2..461b5a9fc838 100644
@@ -265,6 +265,7 @@ config SYS_64BIT_LBA
 
 config RKMTD
 	bool "Rockchip rkmtd virtual block device"
+	select DEVRES
 	select RANDOM_UUID
 	help
 	  Enable "rkmtd" class and driver to create a virtual block device
drivers/clk/Kconfig +1 -0
index 85cc472b4cb9..ae783254008c 100644
@@ -3,6 +3,7 @@ menu "Clock"
 config CLK
 	bool "Enable clock driver support"
 	depends on DM
+	select DEVRES
 	help
 	  This allows drivers to be provided for clock generators, including
 	  oscillators and PLLs. Devices can use a common clock API to request
drivers/core/Kconfig +6 -4
index 6b4330fe4ea3..c9253099e6ea 100644
@@ -197,6 +197,7 @@ config DM_DMA
 config REGMAP
 	bool "Support register maps"
 	depends on DM
+	select DEVRES
 	help
 	  Hardware peripherals tend to have one or more sets of registers
 	  which can be accessed to control the hardware. A register map
@@ -271,16 +272,17 @@ config VPL_SYSCON
 	  assigning a unique number to each.
 
 config DEVRES
-	bool "Managed device resources"
+	bool
 	depends on DM
 	help
 	  This option enables the Managed device resources core support.
 	  Device resources managed by the devres framework are automatically
 	  released whether initialization fails half-way or the device gets
-	  detached.
+	  detached. This is most often used via devm_kmalloc and family and
+	  is expected to work in a manner analogous to the Linux Kernel.
 
-	  If this option is disabled, devres functions fall back to
-	  non-managed variants.  For example, devres_alloc() to kzalloc(),
+	  This option is disabled in xPL phases and devres functions fall back
+	  to non-managed variants. For example, devres_alloc() to kzalloc(),
 	  devm_kmalloc() to kmalloc(), etc.
 
 config DEBUG_DEVRES
drivers/dma/ti/Kconfig +1 -0
index 87c026e04903..5cec6ddd3e30 100644
@@ -5,6 +5,7 @@ if ARCH_K3
 config TI_K3_NAVSS_UDMA
         bool "Texas Instruments UDMA"
         depends on ARCH_K3
+        select DEVRES
         select DMA
         select TI_K3_NAVSS_RINGACC
         select TI_K3_NAVSS_PSILCFG
drivers/firmware/Kconfig +1 -0
index a094e6c3afef..220de7319506 100644
@@ -16,6 +16,7 @@ config ARM_PSCI_FW
 config TI_SCI_PROTOCOL
 	tristate "TI System Control Interface (TISCI) Message Protocol"
 	depends on K3_SEC_PROXY
+	select DEVRES
 	select FIRMWARE
 	select SPL_FIRMWARE if SPL
 	help
drivers/firmware/arm-ffa/Kconfig +1 -0
index d75f8b53fd85..3706a8893059 100644
@@ -6,6 +6,7 @@ config ARM_FFA_TRANSPORT
 	select ARM_SMCCC if !SANDBOX
 	select ARM_SMCCC_FEATURES if !SANDBOX
 	imply CMD_ARMFFA
+	select DEVRES
 	select LIB_UUID
 	select DEVRES
 	help
drivers/gpio/Kconfig +3 -0
index 18ca8ad4caca..60c5c54688e6 100644
@@ -19,6 +19,7 @@ if GPIO
 config DM_GPIO
 	bool "Enable Driver Model for GPIO drivers"
 	depends on DM
+	select DEVRES
 	help
 	  Enable driver model for GPIO access. The standard GPIO
 	  interface (gpio_get_value(), etc.) is then implemented by
@@ -151,6 +152,7 @@ config CORTINA_GPIO
 config DWAPB_GPIO
 	bool "DWAPB GPIO driver"
 	depends on DM && DM_GPIO
+	select DEVRES
 	help
 	  Support for the Designware APB GPIO driver.
 
@@ -253,6 +255,7 @@ config IMX_RGPIO2P
 
 config IPROC_GPIO
 	bool "Broadcom iProc GPIO driver(without pinconf)"
+	select DEVRES
 	help
 	  The Broadcom iProc based SoCs- Cygnus, NS2, NS3, NSP and Stingray,
 	  use the same GPIO Controller IP hence this driver could be used
drivers/i2c/muxes/Kconfig +1 -0
index 65319bb6fd83..3b1220b21056 100644
@@ -51,6 +51,7 @@ config I2C_MUX_PCA954x
 config I2C_MUX_GPIO
         tristate "GPIO-based I2C multiplexer"
 	depends on I2C_MUX && DM_GPIO
+	select DEVRES
 	help
 	  If you say yes to this option, support will be included for
 	  a GPIO based I2C multiplexer. This driver provides access to
drivers/i3c/Kconfig +1 -0
index d877a7443538..48341f9b8737 100644
@@ -1,6 +1,7 @@
 menuconfig I3C
 	tristate "I3C support"
 	select I2C
+	select DEVRES
 	help
 	  I3C is a serial protocol standardized by the MIPI alliance.
 
drivers/mailbox/Kconfig +1 -0
index cfd2a3be3fd0..f45e611c9662 100644
@@ -31,6 +31,7 @@ config IMX_MU_MBOX
 config MPFS_MBOX
 	bool "Enable MPFS system controller support"
 	depends on DM_MAILBOX && ARCH_RV64I
+	select DEVRES
 	help
 	  Enable support for the mailboxes that provide a communication
 	  channel with the system controller integrated on PolarFire SoC.
drivers/mtd/nand/raw/Kconfig +5 -0
index 5e4d1c0a9378..e0ff28cb21bd 100644
@@ -51,6 +51,7 @@ config DM_NAND_ATMEL
 	bool "Support Atmel NAND controller with DM support"
 	depends on ARCH_AT91
 	select ATMEL_EBI
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	imply SYS_NAND_USE_FLASH_BBT
 	help
@@ -74,6 +75,7 @@ config ATMEL_NAND_HWECC
 config ATMEL_NAND_HW_PMECC
 	bool "Atmel Programmable Multibit ECC (PMECC)"
 	select ATMEL_NAND_HWECC
+	select DEVRES
 	help
 	  The Programmable Multibit ECC (PMECC) controller is a programmable
 	  binary BCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder.
@@ -118,6 +120,7 @@ config NAND_BRCMNAND
 	bool "Support Broadcom NAND controller"
 	depends on OF_CONTROL && DM && DM_MTD
 	depends on ARCH_BCMBCA || ARCH_BMIPS || TARGET_BCMNS || TARGET_BCMNS3
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	help
 	  Enable the driver for NAND flash on platforms using a Broadcom NAND
@@ -197,6 +200,7 @@ config SPL_NAND_LOAD
 config NAND_CADENCE
 	bool "Support Cadence NAND controller as a DT device"
 	depends on OF_CONTROL && DM_MTD && ARCH_SOCFPGA
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	select SPL_SYS_NAND_SELF_INIT
 	select SPL_NAND_BASE
@@ -211,6 +215,7 @@ config NAND_CADENCE
 
 config NAND_DENALI
 	bool
+	select DEVRES
 	select SYS_NAND_SELF_INIT
 	select SYS_NAND_ONFI_DETECTION if TARGET_SOCFPGA_SOC64
 	imply CMD_NAND
drivers/mtd/nand/spi/Kconfig +1 -0
index 0777dfdf0a70..1124dada9506 100644
@@ -1,6 +1,7 @@
 menuconfig MTD_SPI_NAND
 	bool "SPI NAND device Support"
 	depends on DM_MTD && DM_SPI
+	select DEVRES
 	select MTD_NAND_CORE
 	select SPI_MEM
 	help
drivers/mtd/spi/Kconfig +1 -0
index ca60a425ba34..a13c7fc60e68 100644
@@ -3,6 +3,7 @@ menu "SPI Flash Support"
 config DM_SPI_FLASH
 	bool "Enable Driver Model for SPI flash"
 	depends on DM_SPI
+	select DEVRES
 	imply SPI_FLASH
 	help
 	  Enable driver model for SPI flash. This SPI flash interface
drivers/mux/Kconfig +1 -0
index 2b95eb02177c..de74e5d5e4ed 100644
@@ -3,6 +3,7 @@ menu "Multiplexer drivers"
 config MULTIPLEXER
 	bool "Multiplexer Support"
 	depends on DM
+	select DEVRES
 	help
 	 The mux framework is a minimalistic subsystem that handles multiplexer
 	 controllers. It provides the same API as Linux and mux drivers should
drivers/net/Kconfig +3 -0
index f382a7752d53..13e631c55dc2 100644
@@ -125,6 +125,7 @@ config AIROHA_ETH
 	bool "Airoha Ethernet QDMA Driver"
 	depends on ARCH_AIROHA
 	select PHYLIB
+	select DEVRES
 	select DM_RESET
 	select MDIO_MT7531
 	help
@@ -359,6 +360,7 @@ config ETH_SANDBOX_RAW
 
 config ETH_DESIGNWARE
 	bool "Synopsys Designware Ethernet MAC"
+	select DEVRES
 	select PHYLIB
 	imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA
 	help
@@ -555,6 +557,7 @@ config MVNETA
 config MVPP2
 	bool "Marvell Armada 375/7K/8K network interface support"
 	depends on ARMADA_375 || ARMADA_8K
+	select DEVRES
 	select PHYLIB
 	select MVMDIO
 	select DM_MDIO
drivers/net/phy/Kconfig +2 -0
index d0aab0b8fe87..709f1c91eb2d 100644
@@ -182,6 +182,7 @@ config PHY_MARVELL
 
 config PHY_MARVELL_10G
 	bool "Marvell Alaska 10Gbit PHYs"
+	select DEVRES
 	help
 	  Support for the Marvell Alaska MV88X3310 and compatible PHYs.
 
@@ -245,6 +246,7 @@ config PHY_NATSEMI
 
 config PHY_NXP_C45_TJA11XX
 	tristate "NXP C45 TJA11XX PHYs"
+	select DEVRES
 	help
 	  Enable support for NXP C45 TJA11XX PHYs.
 	  Currently supports only the TJA1103 PHY.
drivers/pci/Kconfig +3 -0
index ea9868425d04..8fc57895a786 100644
@@ -131,6 +131,7 @@ config PCIE_APPLE
 	bool "Enable Apple PCIe driver"
 	depends on ARCH_APPLE
 	imply PCI_INIT_R
+	select DEVRES
 	select SYS_PCI_64BIT
 	default y
 	help
@@ -264,6 +265,7 @@ config PCI_XILINX
 
 config PCIE_LAYERSCAPE
 	bool
+	select DEVRES
 
 config PCIE_LAYERSCAPE_RC
 	bool "Layerscape PCIe Root Complex mode support"
@@ -361,6 +363,7 @@ config PCI_KEYSTONE
 config PCIE_MEDIATEK
 	bool "MediaTek PCIe Gen2 controller"
 	depends on ARCH_MEDIATEK
+	select DEVRES
 	help
 	  Say Y here if you want to enable Gen2 PCIe controller,
 	  which could be found on MT7623 SoC family.
drivers/phy/Kconfig +1 -0
index 420d7c7a44dd..87729b479bd9 100644
@@ -4,6 +4,7 @@ menu "PHY Subsystem"
 config PHY
 	bool "PHY Core"
 	depends on DM
+	select DEVRES
 	help
 	  PHY support.
 
drivers/pinctrl/Kconfig +1 -0
index 48119694031d..ea90713ec6ca 100644
@@ -294,6 +294,7 @@ config PINCTRL_SANDBOX
 config PINCTRL_SINGLE
 	bool "Single register pin-control and pin-multiplex driver"
 	depends on DM
+	select DEVRES
 	help
 	  This enables pinctrl driver for systems using a single register for
 	  pin configuration and multiplexing. TI's AM335X SoCs are examples of
drivers/pinctrl/mscc/Kconfig +1 -0
index aab67fabd2cd..567c93f404cc 100644
@@ -2,6 +2,7 @@
 
 config PINCTRL_MSCC
 	bool
+	select DEVRES
 
 config PINCTRL_MSCC_OCELOT
 	depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
drivers/pinctrl/mvebu/Kconfig +1 -0
index 7c51d138c8bd..10ba440f246e 100644
@@ -9,6 +9,7 @@ config PINCTRL_ARMADA_38X
 
 config PINCTRL_ARMADA_37XX
 	depends on ARMADA_3700 && PINCTRL_FULL
+	select DEVRES
 	bool "Armada 37xx pin control driver"
 	help
 	   Support pin multiplexing and pin configuration control on
drivers/pinctrl/renesas/Kconfig +1 -0
index ac40b31dbfaa..171da88cfcf4 100644
@@ -166,6 +166,7 @@ config PINCTRL_RZG2L
 	depends on PINCTRL
 	depends on PINCTRL_GENERIC
 	depends on PINCONF
+	select DEVRES
 	help
 	  Support the pinctrl functionality of the pin function controller (PFC)
 	  on the Renesas RZ/G2L SoC family.
drivers/power/regulator/Kconfig +1 -0
index c6da459a212a..bd9ccd26981a 100644
@@ -228,6 +228,7 @@ config DM_REGULATOR_GPIO
 config DM_REGULATOR_QCOM_RPMH
 	bool "Enable driver model for Qualcomm RPMh regulator"
 	depends on DM_REGULATOR && QCOM_RPMH
+	select DEVRES
 	---help---
 	  Enable support for the Qualcomm RPMh regulator. The driver
 	  implements get/set api for a limited set of regulators used
drivers/reboot-mode/Kconfig +1 -0
index bb5189351881..72b33d712235 100644
@@ -9,6 +9,7 @@ menu "Reboot Mode Support"
 config DM_REBOOT_MODE
 	bool "Enable reboot mode using Driver Model"
 	depends on DM
+	select DEVRES
 	help
 		Enable support for reboot mode control. This will allow users to
 		adjust the boot process based on reboot mode parameter
drivers/reset/Kconfig +1 -0
index 74c267dfc4e5..2fd91d6299cc 100644
@@ -3,6 +3,7 @@ menu "Reset Controller Support"
 config DM_RESET
 	bool "Enable reset controllers using Driver Model"
 	depends on DM && OF_CONTROL
+	select DEVRES
 	help
 	  Enable support for the reset controller driver class. Many hardware
 	  modules are equipped with a reset signal, typically driven by some
drivers/smem/Kconfig +1 -0
index 73d51b3a7a48..e5d7dcc81b17 100644
@@ -16,6 +16,7 @@ config MSM_SMEM
     bool "Qualcomm Shared Memory Manager (SMEM)"
     depends on DM
     depends on ARCH_SNAPDRAGON || ARCH_IPQ40XX
+    select DEVRES
     help
       Enable support for the Qualcomm Shared Memory Manager.
       The driver provides an interface to items in a heap shared among all
drivers/soc/ti/Kconfig +1 -0
index 0ee21f990488..36129cb72f68 100644
@@ -8,6 +8,7 @@ if SOC_TI
 config TI_K3_NAVSS_RINGACC
 	bool "K3 Ring accelerator Sub System"
 	depends on ARCH_K3
+	select DEVRES
 	select MISC
 	help
 	  Say y here to support the K3 AM65x Ring accelerator module.
drivers/spi/Kconfig +2 -0
index e31db9d4e31b..50d22bf3fc4c 100644
@@ -35,6 +35,7 @@ config DM_SPI
 
 config SPI_MEM
 	bool "SPI memory extension"
+	select DEVRES
 	help
 	  Enable this option if you want to enable the SPI memory extension.
 	  This extension is meant to simplify interaction with SPI memories
@@ -343,6 +344,7 @@ config MT7621_SPI
 config MTK_SNOR
 	bool "Mediatek SPI-NOR controller driver"
 	depends on SPI_MEM
+	select DEVRES
 	help
 	  Enable the Mediatek SPINOR controller driver. This driver has
           better read/write performance with NOR.
drivers/usb/cdns3/Kconfig +1 -0
index 1d5e4afac6cd..7964f3f41d5e 100644
@@ -1,6 +1,7 @@
 config USB_CDNS3
 	tristate "Cadence USB3 Dual-Role Controller"
 	depends on USB_XHCI_HCD || USB_GADGET
+	select DEVRES
 	help
 	  Say Y here if your system has a Cadence USB3 dual-role controller.
 	  It supports: Host-only, and Peripheral-only.
drivers/usb/dwc3/Kconfig +1 -0
index 744dfa90463c..27fcae54b227 100644
@@ -1,6 +1,7 @@
 config USB_DWC3
 	bool "DesignWare USB3 DRD Core Support"
 	depends on USB_XHCI_HCD || USB_GADGET
+	select DEVRES
 	help
 	  Say Y here if your system has a Dual Role SuperSpeed
 	  USB controller based on the DesignWare USB3 IP Core.
drivers/usb/host/Kconfig +1 -0
index 99f381db9f9b..54df4264a441 100644
@@ -367,6 +367,7 @@ config USB_OHCI_GENERIC
 config USB_OHCI_DA8XX
 	bool "Support for da850 OHCI USB controller"
 	depends on ARCH_DAVINCI
+	select DEVRES
 	help
 	  Enable support for the da850 USB controller.
 
drivers/video/Kconfig +1 -0
index b5777da5218a..2c67d089492c 100644
@@ -831,6 +831,7 @@ config BACKLIGHT_LM3533
 config BACKLIGHT_LP855x
 	bool "Backlight Driver for LP855x"
 	depends on BACKLIGHT
+	select DEVRES
 	select DM_I2C
 	help
 	  Say Y to enable the backlight driver for National Semiconductor / TI
include/dm/devres.h +2 -1
index 27761deb6d1f..406d18686f4d 100644
@@ -207,7 +207,8 @@ void devm_kfree(struct udevice *dev, void *ptr);
 /* Get basic stats on allocations */
 void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);
 
-#else /* ! DEVRES */
+#elif IS_ENABLED(CONFIG_DEVRES) && defined(CONFIG_XPL_BUILD)
+/* Allow these to be dummy functions in xPL builds. */
 
 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {
Signature · 1 line
2.43.0
#20 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Hi all,

Quoted 15 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model
where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver author expects that since the functions have the same name as in the Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations by enabling the DEVRES functionality (outside of xPL phases).

Quoted 4 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle Kit with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm: core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on this board. After this patch was applied the Icicle kit no longer boots and crashes immediately after OpenSBI. Between this patch and master HEAD the following errors are found - please see attached logs for more detail:

Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction” and a reset.

The last known good commit is before this commmit. I used git bisect to confirm that 217cf656e249 (this patch) is the first bad commit.

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot for this
- Observe the boot failure after the above commit

Any advise on the problem?

Thanks,
Jamie Gibbons

Quoted 619 lines

---
Changes in v2:
- Fix typo that Michael spotted
- Reword the commit message to try and be clearer about the problem today.
- Add Michael's tag.
- Expand the help text around DEVRES slightly to include mentioning devm_kmalloc and family and that it should work like in the Linux Kernel.
---
 arch/arm/mach-stm32mp/Kconfig    |  1 + drivers/block/Kconfig            |  1 + drivers/clk/Kconfig              |  1 + drivers/core/Kconfig             | 10 ++++++---- drivers/dma/ti/Kconfig           |  1 + drivers/firmware/Kconfig         |  1 + drivers/firmware/arm-ffa/Kconfig |  1 + drivers/gpio/Kconfig             |  3 +++ drivers/i2c/muxes/Kconfig        |  1 + drivers/i3c/Kconfig              |  1 + drivers/mailbox/Kconfig          |  1 + drivers/mtd/nand/raw/Kconfig     |  5 +++++ drivers/mtd/nand/spi/Kconfig     |  1 + drivers/mtd/spi/Kconfig          |  1 + drivers/mux/Kconfig              |  1 + drivers/net/Kconfig              |  3 +++ drivers/net/phy/Kconfig          |  2 ++ drivers/pci/Kconfig              |  3 +++ drivers/phy/Kconfig              |  1 + drivers/pinctrl/Kconfig          |  1 + drivers/pinctrl/mscc/Kconfig     |  1 + drivers/pinctrl/mvebu/Kconfig    |  1 + drivers/pinctrl/renesas/Kconfig  |  1 + drivers/power/regulator/Kconfig  |  1 + drivers/reboot-mode/Kconfig      |  1 + drivers/reset/Kconfig            |  1 + drivers/smem/Kconfig             |  1 + drivers/soc/ti/Kconfig           |  1 + drivers/spi/Kconfig              |  2 ++ drivers/usb/cdns3/Kconfig        |  1 + drivers/usb/dwc3/Kconfig         |  1 + drivers/usb/host/Kconfig         |  1 + drivers/video/Kconfig            |  1 + include/dm/devres.h              |  3 ++-

 34 files changed, 52 insertions(+), 5 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-stm32mp/Kconfig +0 -0

stm32mp/Kconfig
index ba4694f29644..2716844b2599 100644

arch/arm/mach-stm32mp/Kconfig +0 -0
@@ -170,6 +170,7 @@ config STM32_ECDSA_VERIFY


 config STM32MP_TAMP_NVMEM
        bool "STM32 TAMP backup registers via NVMEM API" +       select DEVRES
        select NVMEM
        default y
        help

drivers/block/Kconfig +0 -0
index 185da2b5cfc2..461b5a9fc838 100644
@@ -265,6 +265,7 @@ config SYS_64BIT_LBA


 config RKMTD
        bool "Rockchip rkmtd virtual block device"
+       select DEVRES
        select RANDOM_UUID
        help
          Enable "rkmtd" class and driver to create a virtual block device

drivers/clk/Kconfig +0 -0
index 85cc472b4cb9..ae783254008c 100644
@@ -3,6 +3,7 @@ menu "Clock"

 config CLK
        bool "Enable clock driver support"
        depends on DM
+       select DEVRES
        help
          This allows drivers to be provided for clock generators, including
          oscillators and PLLs. Devices can use a common clock API to request

drivers/core/Kconfig +0 -0
index 6b4330fe4ea3..c9253099e6ea 100644
@@ -197,6 +197,7 @@ config DM_DMA

 config REGMAP
        bool "Support register maps"
        depends on DM
+       select DEVRES
        help
          Hardware peripherals tend to have one or more sets of registers
          which can be accessed to control the hardware. A register map

drivers/core/Kconfig +0 -0
@@ -271,16 +272,17 @@ config VPL_SYSCON

          assigning a unique number to each.

 config DEVRES
-       bool "Managed device resources"
+       bool
        depends on DM
        help
          This option enables the Managed device resources core support.
          Device resources managed by the devres framework are automatically
          released whether initialization fails half-way or the device gets
-         detached.
+         detached. This is most often used via devm_kmalloc and family and
+         is expected to work in a manner analogous to the Linux Kernel.

-         If this option is disabled, devres functions fall back to -         non-managed variants.  For example, devres_alloc() to kzalloc(),
+         This option is disabled in xPL phases and devres functions fall back
+         to non-managed variants. For example, devres_alloc() to kzalloc(),
          devm_kmalloc() to kmalloc(), etc.

 config DEBUG_DEVRES

drivers/dma/ti/Kconfig +0 -0
index 87c026e04903..5cec6ddd3e30 100644
@@ -5,6 +5,7 @@ if ARCH_K3

 config TI_K3_NAVSS_UDMA
         bool "Texas Instruments UDMA"
         depends on ARCH_K3
+        select DEVRES
         select DMA
         select TI_K3_NAVSS_RINGACC
         select TI_K3_NAVSS_PSILCFG

drivers/firmware/Kconfig +0 -0
index a094e6c3afef..220de7319506 100644
@@ -16,6 +16,7 @@ config ARM_PSCI_FW

 config TI_SCI_PROTOCOL
        tristate "TI System Control Interface (TISCI) Message Protocol"
        depends on K3_SEC_PROXY
+       select DEVRES
        select FIRMWARE
        select SPL_FIRMWARE if SPL
        help

drivers/firmware/arm- renamed from drivers/firmware/arm-ffa/Kconfig +0 -0

ffa/Kconfig
index d75f8b53fd85..3706a8893059 100644

drivers/firmware/arm-ffa/Kconfig +0 -0
@@ -6,6 +6,7 @@ config ARM_FFA_TRANSPORT

        select ARM_SMCCC if !SANDBOX
        select ARM_SMCCC_FEATURES if !SANDBOX
        imply CMD_ARMFFA
+       select DEVRES
        select LIB_UUID
        select DEVRES
        help

drivers/gpio/Kconfig +0 -0
index 18ca8ad4caca..60c5c54688e6 100644
@@ -19,6 +19,7 @@ if GPIO

 config DM_GPIO
        bool "Enable Driver Model for GPIO drivers" depends on DM
+       select DEVRES
        help
          Enable driver model for GPIO access. The standard GPIO interface (gpio_get_value(), etc.) is then implemented by

drivers/gpio/Kconfig +0 -0
@@ -151,6 +152,7 @@ config CORTINA_GPIO

 config DWAPB_GPIO
        bool "DWAPB GPIO driver"
        depends on DM && DM_GPIO
+       select DEVRES
        help
          Support for the Designware APB GPIO driver.

drivers/gpio/Kconfig +0 -0
@@ -253,6 +255,7 @@ config IMX_RGPIO2P


 config IPROC_GPIO
        bool "Broadcom iProc GPIO driver(without pinconf)" +       select DEVRES
        help
          The Broadcom iProc based SoCs- Cygnus, NS2, NS3, NSP and Stingray,
          use the same GPIO Controller IP hence this driver could be used

drivers/i2c/muxes/Kconfig +0 -0
index 65319bb6fd83..3b1220b21056 100644
@@ -51,6 +51,7 @@ config I2C_MUX_PCA954x

 config I2C_MUX_GPIO
         tristate "GPIO-based I2C multiplexer"
        depends on I2C_MUX && DM_GPIO
+       select DEVRES
        help
          If you say yes to this option, support will be included for a GPIO based I2C multiplexer. This driver provides access to

drivers/i3c/Kconfig +0 -0
index d877a7443538..48341f9b8737 100644
@@ -1,6 +1,7 @@

 menuconfig I3C
        tristate "I3C support"
        select I2C
+       select DEVRES
        help
          I3C is a serial protocol standardized by the MIPI alliance.

drivers/mailbox/Kconfig +0 -0
index cfd2a3be3fd0..f45e611c9662 100644
@@ -31,6 +31,7 @@ config IMX_MU_MBOX

 config MPFS_MBOX
        bool "Enable MPFS system controller support" depends on DM_MAILBOX && ARCH_RV64I
+       select DEVRES
        help
          Enable support for the mailboxes that provide a communication
          channel with the system controller integrated on PolarFire SoC.

drivers/mtd/nand/raw/Kconfig +0 -0
index 5e4d1c0a9378..e0ff28cb21bd 100644
@@ -51,6 +51,7 @@ config DM_NAND_ATMEL

        bool "Support Atmel NAND controller with DM support" depends on ARCH_AT91
        select ATMEL_EBI
+       select DEVRES
        select SYS_NAND_SELF_INIT
        imply SYS_NAND_USE_FLASH_BBT
        help

drivers/mtd/nand/raw/Kconfig +0 -0
@@ -74,6 +75,7 @@ config ATMEL_NAND_HWECC

 config ATMEL_NAND_HW_PMECC
        bool "Atmel Programmable Multibit ECC (PMECC)" select ATMEL_NAND_HWECC
+       select DEVRES
        help
          The Programmable Multibit ECC (PMECC) controller is a programmable
          binary BCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder.

drivers/mtd/nand/raw/Kconfig +0 -0
@@ -118,6 +120,7 @@ config NAND_BRCMNAND

        bool "Support Broadcom NAND controller" depends on OF_CONTROL && DM && DM_MTD
        depends on ARCH_BCMBCA || ARCH_BMIPS || TARGET_BCMNS || TARGET_BCMNS3
+       select DEVRES
        select SYS_NAND_SELF_INIT
        help
          Enable the driver for NAND flash on platforms using a Broadcom NAND

drivers/mtd/nand/raw/Kconfig +0 -0
@@ -197,6 +200,7 @@ config SPL_NAND_LOAD

 config NAND_CADENCE
        bool "Support Cadence NAND controller as a DT device" depends on OF_CONTROL && DM_MTD && ARCH_SOCFPGA +       select DEVRES
        select SYS_NAND_SELF_INIT
        select SPL_SYS_NAND_SELF_INIT
        select SPL_NAND_BASE

drivers/mtd/nand/raw/Kconfig +0 -0
@@ -211,6 +215,7 @@ config NAND_CADENCE


 config NAND_DENALI
        bool
+       select DEVRES
        select SYS_NAND_SELF_INIT
        select SYS_NAND_ONFI_DETECTION if TARGET_SOCFPGA_SOC64 imply CMD_NAND

drivers/mtd/nand/spi/Kconfig +0 -0
index 0777dfdf0a70..1124dada9506 100644
@@ -1,6 +1,7 @@

 menuconfig MTD_SPI_NAND
        bool "SPI NAND device Support"
        depends on DM_MTD && DM_SPI
+       select DEVRES
        select MTD_NAND_CORE
        select SPI_MEM
        help

drivers/mtd/spi/Kconfig +0 -0
index ca60a425ba34..a13c7fc60e68 100644
@@ -3,6 +3,7 @@ menu "SPI Flash Support"

 config DM_SPI_FLASH
        bool "Enable Driver Model for SPI flash"
        depends on DM_SPI
+       select DEVRES
        imply SPI_FLASH
        help
          Enable driver model for SPI flash. This SPI flash interface

drivers/mux/Kconfig +0 -0
index 2b95eb02177c..de74e5d5e4ed 100644
@@ -3,6 +3,7 @@ menu "Multiplexer drivers"

 config MULTIPLEXER
        bool "Multiplexer Support"
        depends on DM
+       select DEVRES
        help
         The mux framework is a minimalistic subsystem that handles multiplexer
         controllers. It provides the same API as Linux and mux drivers should

drivers/net/Kconfig +0 -0
index f382a7752d53..13e631c55dc2 100644
@@ -125,6 +125,7 @@ config AIROHA_ETH

        bool "Airoha Ethernet QDMA Driver"
        depends on ARCH_AIROHA
        select PHYLIB
+       select DEVRES
        select DM_RESET
        select MDIO_MT7531
        help

drivers/net/Kconfig +0 -0
@@ -359,6 +360,7 @@ config ETH_SANDBOX_RAW


 config ETH_DESIGNWARE
        bool "Synopsys Designware Ethernet MAC" +       select DEVRES
        select PHYLIB
        imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA help

drivers/net/Kconfig +0 -0
@@ -555,6 +557,7 @@ config MVNETA

 config MVPP2
        bool "Marvell Armada 375/7K/8K network interface support" depends on ARMADA_375 || ARMADA_8K
+       select DEVRES
        select PHYLIB
        select MVMDIO
        select DM_MDIO

drivers/net/phy/Kconfig +0 -0
index d0aab0b8fe87..709f1c91eb2d 100644
@@ -182,6 +182,7 @@ config PHY_MARVELL


 config PHY_MARVELL_10G
        bool "Marvell Alaska 10Gbit PHYs"
+       select DEVRES
        help
          Support for the Marvell Alaska MV88X3310 and compatible PHYs.

drivers/net/phy/Kconfig +0 -0
@@ -245,6 +246,7 @@ config PHY_NATSEMI


 config PHY_NXP_C45_TJA11XX
        tristate "NXP C45 TJA11XX PHYs"
+       select DEVRES
        help
          Enable support for NXP C45 TJA11XX PHYs. Currently supports only the TJA1103 PHY.

drivers/pci/Kconfig +0 -0
index ea9868425d04..8fc57895a786 100644
@@ -131,6 +131,7 @@ config PCIE_APPLE

        bool "Enable Apple PCIe driver"
        depends on ARCH_APPLE
        imply PCI_INIT_R
+       select DEVRES
        select SYS_PCI_64BIT
        default y
        help

drivers/pci/Kconfig +0 -0
@@ -264,6 +265,7 @@ config PCI_XILINX


 config PCIE_LAYERSCAPE
        bool
+       select DEVRES

 config PCIE_LAYERSCAPE_RC
        bool "Layerscape PCIe Root Complex mode support"

drivers/pci/Kconfig +0 -0
@@ -361,6 +363,7 @@ config PCI_KEYSTONE

 config PCIE_MEDIATEK
        bool "MediaTek PCIe Gen2 controller"
        depends on ARCH_MEDIATEK
+       select DEVRES
        help
          Say Y here if you want to enable Gen2 PCIe controller, which could be found on MT7623 SoC family.

drivers/phy/Kconfig +0 -0
index 420d7c7a44dd..87729b479bd9 100644
@@ -4,6 +4,7 @@ menu "PHY Subsystem"

 config PHY
        bool "PHY Core"
        depends on DM
+       select DEVRES
        help
          PHY support.

drivers/pinctrl/Kconfig +0 -0
index 48119694031d..ea90713ec6ca 100644
@@ -294,6 +294,7 @@ config PINCTRL_SANDBOX

 config PINCTRL_SINGLE
        bool "Single register pin-control and pin-multiplex driver" depends on DM
+       select DEVRES
        help
          This enables pinctrl driver for systems using a single register for
          pin configuration and multiplexing. TI's AM335X SoCs are examples of

drivers/pinctrl/mscc/Kconfig +0 -0
index aab67fabd2cd..567c93f404cc 100644
@@ -2,6 +2,7 @@


 config PINCTRL_MSCC
        bool
+       select DEVRES

 config PINCTRL_MSCC_OCELOT
        depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL

drivers/pinctrl/mvebu/Kconfig +0 -0
index 7c51d138c8bd..10ba440f246e 100644
@@ -9,6 +9,7 @@ config PINCTRL_ARMADA_38X


 config PINCTRL_ARMADA_37XX
        depends on ARMADA_3700 && PINCTRL_FULL
+       select DEVRES
        bool "Armada 37xx pin control driver"
        help
           Support pin multiplexing and pin configuration control on

drivers/pinctrl/renesas/Kconfig +0 -0
index ac40b31dbfaa..171da88cfcf4 100644
@@ -166,6 +166,7 @@ config PINCTRL_RZG2L

        depends on PINCTRL
        depends on PINCTRL_GENERIC
        depends on PINCONF
+       select DEVRES
        help
          Support the pinctrl functionality of the pin function controller (PFC)
          on the Renesas RZ/G2L SoC family.

drivers/power/regulator/Kconfig +0 -0
index c6da459a212a..bd9ccd26981a 100644
@@ -228,6 +228,7 @@ config DM_REGULATOR_GPIO

 config DM_REGULATOR_QCOM_RPMH
        bool "Enable driver model for Qualcomm RPMh regulator" depends on DM_REGULATOR && QCOM_RPMH
+       select DEVRES
        ---help---
          Enable support for the Qualcomm RPMh regulator. The driver implements get/set api for a limited set of regulators used

drivers/reboot-mode/Kconfig +0 -0
index bb5189351881..72b33d712235 100644
@@ -9,6 +9,7 @@ menu "Reboot Mode Support"

 config DM_REBOOT_MODE
        bool "Enable reboot mode using Driver Model" depends on DM
+       select DEVRES
        help
                Enable support for reboot mode control. This will allow users to
                adjust the boot process based on reboot mode parameter

drivers/reset/Kconfig +0 -0
index 74c267dfc4e5..2fd91d6299cc 100644
@@ -3,6 +3,7 @@ menu "Reset Controller Support"

 config DM_RESET
        bool "Enable reset controllers using Driver Model" depends on DM && OF_CONTROL
+       select DEVRES
        help
          Enable support for the reset controller driver class. Many hardware
          modules are equipped with a reset signal, typically driven by some

drivers/smem/Kconfig +0 -0
index 73d51b3a7a48..e5d7dcc81b17 100644
@@ -16,6 +16,7 @@ config MSM_SMEM

     bool "Qualcomm Shared Memory Manager (SMEM)" depends on DM
     depends on ARCH_SNAPDRAGON || ARCH_IPQ40XX
+    select DEVRES
     help
       Enable support for the Qualcomm Shared Memory Manager. The driver provides an interface to items in a heap shared among all

drivers/soc/ti/Kconfig +0 -0
index 0ee21f990488..36129cb72f68 100644
@@ -8,6 +8,7 @@ if SOC_TI

 config TI_K3_NAVSS_RINGACC
        bool "K3 Ring accelerator Sub System"
        depends on ARCH_K3
+       select DEVRES
        select MISC
        help
          Say y here to support the K3 AM65x Ring accelerator module.

drivers/spi/Kconfig +0 -0
index e31db9d4e31b..50d22bf3fc4c 100644
@@ -35,6 +35,7 @@ config DM_SPI


 config SPI_MEM
        bool "SPI memory extension"
+       select DEVRES
        help
          Enable this option if you want to enable the SPI memory extension.
          This extension is meant to simplify interaction with SPI memories

drivers/spi/Kconfig +0 -0
@@ -343,6 +344,7 @@ config MT7621_SPI

 config MTK_SNOR
        bool "Mediatek SPI-NOR controller driver" depends on SPI_MEM
+       select DEVRES
        help
          Enable the Mediatek SPINOR controller driver. This driver has
           better read/write performance with NOR.

drivers/usb/cdns3/Kconfig +0 -0
index 1d5e4afac6cd..7964f3f41d5e 100644
@@ -1,6 +1,7 @@

 config USB_CDNS3
        tristate "Cadence USB3 Dual-Role Controller" depends on USB_XHCI_HCD || USB_GADGET
+       select DEVRES
        help
          Say Y here if your system has a Cadence USB3 dual-role controller.
          It supports: Host-only, and Peripheral-only.

drivers/usb/dwc3/Kconfig +0 -0
index 744dfa90463c..27fcae54b227 100644
@@ -1,6 +1,7 @@

 config USB_DWC3
        bool "DesignWare USB3 DRD Core Support" depends on USB_XHCI_HCD || USB_GADGET
+       select DEVRES
        help
          Say Y here if your system has a Dual Role SuperSpeed USB controller based on the DesignWare USB3 IP Core.

drivers/usb/host/Kconfig +0 -0
index 99f381db9f9b..54df4264a441 100644
@@ -367,6 +367,7 @@ config USB_OHCI_GENERIC

 config USB_OHCI_DA8XX
        bool "Support for da850 OHCI USB controller" depends on ARCH_DAVINCI
+       select DEVRES
        help
          Enable support for the da850 USB controller.

drivers/video/Kconfig +0 -0
index b5777da5218a..2c67d089492c 100644
@@ -831,6 +831,7 @@ config BACKLIGHT_LM3533

 config BACKLIGHT_LP855x
        bool "Backlight Driver for LP855x"
        depends on BACKLIGHT
+       select DEVRES
        select DM_I2C
        help
          Say Y to enable the backlight driver for National Semiconductor / TI

include/dm/devres.h +0 -0
index 27761deb6d1f..406d18686f4d 100644
@@ -207,7 +207,8 @@ void devm_kfree(struct udevice *dev, void *ptr);
  /* Get basic stats on allocations */

 void devres_get_stats(const struct udevice *dev, struct devres_stats *stats);

include/dm/devres.h +2 -1
-#else /* ! DEVRES */
+#elif IS_ENABLED(CONFIG_DEVRES) && defined(CONFIG_XPL_BUILD)
+/* Allow these to be dummy functions in xPL builds. */
Quoted 4 lines


 static inline void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {

U-Boot 2026.01-rc5-00430-g284e1a00f4f2 (Jan 14 2026 - 12:36:45 +0000)

CPU:   sifive,u54-mc
Model: Microchip PolarFire-SoC Icicle Kit
DRAM:  1020 MiB (total 2 GiB)
Core:  66 devices, 15 uclasses, devicetree: fit
MMC:   mmc@20008000: 0
Loading Environment from nowhere... OK
In:    serial@20100000
Out:   serial@20100000
Err:   serial@20100000
Net:   eth1: ethernet@20110000, eth0: ethernet@20112000
Hit any key to stop autoboot: 0

switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:2...
Found U-Boot script /boot.scr
640 bytes read in 8 ms (78.1 KiB/s)
## Executing script at 88100000
Working FDT set to bf349500
6420196 bytes read in 86 ms (71.2 MiB/s)
## Loading kernel (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'kernel' kernel subimage

     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x881000cc
     Data Size:    6361635 Bytes = 6.1 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x80200000
     Entry Point:  0x80200000
     Hash algo:    sha256
     Hash value:   69c78825289e8b4bd5f26b98eb81d67ebc42a9725d393f6b91bb8e35a30215e7

Verifying Hash Integrity ... sha256+ OK
## Loading fdt (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'fdt-mpfs-icicle-kit.dtb' fdt subimage

     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x88711404
     Data Size:    24242 Bytes = 23.7 KiB
     Architecture: RISC-V
     Load Address: 0x8a000000
     Hash algo:    sha256
     Hash value:   2a111f7ecb21056e2e315fab673fef4d566d7cdb0284de3deb3663a4fa07c61f

Verifying Hash Integrity ... sha256+ OK Loading fdt from 0x88711404 to 0x8a000000
Failed to reserve memory for fdt at 0xbf384f80 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
Uncompressing Kernel Image to 80200000
Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

U-Boot 2026.01-00520-gcf51247c632f (Jan 14 2026 - 12:26:20 +0000)

CPU:   sifive,u54-mc
Model: Microchip PolarFire-SoC Icicle Kit
DRAM:  1020 MiB (total 2 GiB)
Core:  66 devices, 15 uclasses, devicetree: fit
MMC:   mmc@20008000: 0
Loading Environment from nowhere... OK
In:    serial@20100000
Out:   serial@20100000
Err:   serial@20100000
Net:   eth1: ethernet@20110000, eth0: ethernet@20112000
Hit any key to stop autoboot: 0

switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:2...
Found U-Boot script /boot.scr
640 bytes read in 8 ms (78.1 KiB/s)
## Executing script at 88100000
Working FDT set to bf349500
6420196 bytes read in 85 ms (72 MiB/s)
## Loading kernel (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'kernel' kernel subimage

     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x881000cc
     Data Size:    6361635 Bytes = 6.1 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x80200000
     Entry Point:  0x80200000
     Hash algo:    sha256
     Hash value:   69c78825289e8b4bd5f26b98eb81d67ebc42a9725d393f6b91bb8e35a30215e7

Verifying Hash Integrity ... sha256+ OK
## Loading fdt (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'fdt-mpfs-icicle-kit.dtb' fdt subimage

     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x88711404
     Data Size:    24242 Bytes = 23.7 KiB
     Architecture: RISC-V
     Load Address: 0x8a000000
     Hash algo:    sha256
     Hash value:   2a111f7ecb21056e2e315fab673fef4d566d7cdb0284de3deb3663a4fa07c61f

Verifying Hash Integrity ... sha256+ OK
Loading fdt from 0x88711404 to 0x8a000000
WARNING:
The 'fdt_high' environment variable is set to ~0. This is known to cause boot failures due to placement of DT at non-8-byte-aligned addresses. This system will likely fail to boot. Unset the 'fdt_high' environment variable and submit a fix upstream.
Failed to reserve memory for fdt at 0xbf384f80
Required FDT relocation for applying DTOs failed: 1
Could not find a valid device tree
Uncompressing Kernel Image to 80200000
Device tree not found or missing FDT support
### ERROR ### Please RESET the board ###

OpenSBI v1.2
____ _____ ____ _____

  / __ \                  / ____|  _ \_   _|
 | |  | |_ __   ___ _ __ | (___ | |_) || |
 | |  | | '_ \ / _ \ '_ \ \___ \|  _ < | |
 | |__| | |_) |  __/ | | |____) | |_) || |_
  \____/| .__/ \___|_| |_|_____/|____/_____|
        | |
        |_|

Platform Name : Microchip PolarFire(R) SoC
Platform Features : medeleg
Platform HART Count : 5
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : mmuart
Platform HSM Device : mpfs_hsm
Platform PMU Device : ---
Platform Reboot Device : mpfs_reset
Platform Shutdown Device : mpfs_reset
Firmware Base : 0xa000000
Firmware Size : 152 KB
Runtime SBI Version : 1.0

Domain0 Name : root
Domain0 Boot HART : 1
Domain0 HARTs : 1,2,3,4
Domain0 Region00 : 0x0000000002008000-0x000000000200bfff (I)
Domain0 Region01 : 0x0000000002000000-0x0000000002007fff (I)
Domain0 Region02 : 0x000000000a000000-0x000000000a03ffff ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x000000000a027418
Domain0 Next Mode : S-mode
Domain0 SysReset : yes

Domain1 Name : src.bin
Domain1 Boot HART : 1
Domain1 HARTs : 1*,2*,3*,4*
Domain1 Region00 : 0x000000000a000000-0x000000000a03ffff ()
Domain1 Region01 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain1 Next Address : 0x0000000080200000
Domain1 Next Arg1 : 0x000000000a027418
Domain1 Next Mode : S-mode
Domain1 SysReset : yes

Boot HART ID : 1
Boot HART Domain : src.bin
Boot HART Priv Version : v1.10
Boot HART Base ISA : rv64imafdc
Boot HART ISA Extensions : none
Boot HART PMP Count : 16
Boot HART PMP Granularity : 4
Boot HART PMP Address Bits: 36
Boot HART MHPM Count : 2
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109

author
#21 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Quoted 44 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 15 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model
where allocations are (almost always) automatically free()'d. However, quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver author expects that since the functions have the same name as in the Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations by enabling the DEVRES functionality (outside of xPL phases).

Quoted 4 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle Kit with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm: core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on this board. After this patch was applied the Icicle kit no longer boots and crashes immediately after OpenSBI. Between this patch and master HEAD the following errors are found - please see attached logs for more detail:

Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction” and a reset.

The last known good commit is before this commmit. I used git bisect to confirm that 217cf656e249 (this patch) is the first bad commit.

Quoted 7 lines

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot for this
- Observe the boot failure after the above commit

Any advise on the problem?

It's really strange that it bisects down to this commit, rather than something device tree related. Do you still have fdt_high=0xffffffff or so set in the environment? It was in at least one of the logs, but I can't see for sure if it's just that the other log is from before the commit that added the print warning about not doing that, or if it wasn't set.

Signature · 1 line
Tom
#22 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Hi Tom,

Quoted 68 lines · Tom Rini
Quoted 57 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 20 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel model
where allocations are (almost always) automatically free()'d. However,
quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver
author expects that since the functions have the same name as in the
Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations by
enabling the DEVRES functionality (outside of xPL phases).

Quoted 5 lines

This turns DEVRES from a prompted symbol to a symbol that must be select'd, and we now remove our non-managed alloc/free functions from
outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle Kit
with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm:
core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on this
board. After this patch was applied the Icicle kit no longer boots and
crashes immediately after OpenSBI. Between this patch and master HEAD
the following errors are found - please see attached logs for more detail:

    Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
    Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction” and
a reset.

The last known good commit is before this commmit. I used git bisect
to confirm that 217cf656e249 (this patch) is the first bad commit.

Quoted 8 lines

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot for
this
- Observe the boot failure after the above commit

Any advise on the problem?

Quoted 8 lines

It's really strange that it bisects down to this commit, rather than something device tree related. Do you still have fdt_high=0xffffffff or
so set in the environment? It was in at least one of the logs, but I can't see for sure if it's just that the other log is from before the commit that added the print warning about not doing that, or if it wasn't set.

Apologies for the daly in my response, I wanted to do some more debugging before getting back to you.

Thanks for the suggestion about fdt_high. We have it set in our boot scripts. I chased this down with a bisect to 9235da9446e (boot: Warn users about fdt_high=~0 usage). I have now set fdt_high to our maximum addressable value instead of ~0. This does get rid of the warning about fdt_high in U-Boot, so that part is resolved.

However, it doesn’t fix the underlying boot issue — U-Boot still fails to boot altogether. During some bisections it often fails to apply device tree overlays and doesn’t boot the kernel - I have attached the latest crash log.

From my bisecting, the overlay breakage seems to start with the DTC/libfdt update commit (0535e46d55d...). After that, overlay application consistently fails, regardless of the fdt_high settings. As an additional piece of information disabling MULT_DTB_FIT allows the board to boot as far as fdt error.

Let me know if you have any other ideas.

Thanks!

U-Boot 2026.01-00492-g1d59479362c7 (Jan 15 2026 - 15:48:22 +0000)

CPU:   sifive,u54-mc
Model: Microchip PolarFire-SoC Icicle Kit
DRAM:  1020 MiB (total 2 GiB)
Core:  66 devices, 15 uclasses, devicetree: fit
MMC:   mmc@20008000: 0
Loading Environment from nowhere... OK
In:    serial@20100000
Out:   serial@20100000
Err:   serial@20100000
Net:   eth1: ethernet@20110000, eth0: ethernet@20112000
Hit any key to stop autoboot: 0

switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:2...
Found U-Boot script /boot.scr
624 bytes read in 8 ms (76.2 KiB/s)
## Executing script at 88100000
Working FDT set to bf349500
6420192 bytes read in 86 ms (71.2 MiB/s)
## Loading kernel (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'kernel' kernel subimage

     Description:  Linux kernel
     Type:         Kernel Image
     Compression:  gzip compressed
     Data Start:   0x881000cc
     Data Size:    6361629 Bytes = 6.1 MiB
     Architecture: RISC-V
     OS:           Linux
     Load Address: 0x80200000
     Entry Point:  0x80200000
     Hash algo:    sha256
     Hash value:   e92dccad51bf9f61f2a08d26a3da904ed5a86950db78d939bd621ef9fe9b95ac

Verifying Hash Integrity ... sha256+ OK
## Loading fdt (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-kit' configuration Trying 'fdt-mpfs-icicle-kit.dtb' fdt subimage

     Description:  Flattened Device Tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x88711400
     Data Size:    24242 Bytes = 23.7 KiB
     Architecture: RISC-V
     Load Address: 0x8a000000
     Hash algo:    sha256
     Hash value:   2a111f7ecb21056e2e315fab673fef4d566d7cdb0284de3deb3663a4fa07c61f

Verifying Hash Integrity ... sha256+ OK
Loading fdt from 0x88711400 to 0x8a000000
Loading Device Tree to 00000000be331000, end 00000000be339fff ... OK
Working FDT set to be331000
## Loading fdt (any) from FIT Image at 88100000 ...
Using 'conf-microchip,mpfs-icicle-cpu-opp' configuration Trying 'fdt-mpfs-icicle-cpu-opp.dtbo' fdt subimage

     Description:  Device Tree blob for CPU Operating Points
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x8871e8a4
     Data Size:    1392 Bytes = 1.4 KiB
     Architecture: RISC-V
     Load Address: 0x8a0c0000
     Hash algo:    sha256
     Hash value:   9355e3feaa4ce663cb5a223ee73a26ef227f02586327b3f9db48b5c35ddcdc78

Verifying Hash Integrity ... sha256+ OK
failed on fdt_open_into for DTO
Could not find a valid device tree
Uncompressing Kernel Image to 80200000
Device tree not found or missing FDT support
### ERROR ### Please RESET the board ###

#23 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Hi Tom,

Quoted 108 lines · Jamie Gibbons

Hi Tom,

Quoted 74 lines · Tom Rini
Quoted 70 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 22 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel
model
where allocations are (almost always) automatically free()'d. However,
quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver
author expects that since the functions have the same name as in the
Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations
by
enabling the DEVRES functionality (outside of xPL phases).

Quoted 6 lines

This turns DEVRES from a prompted symbol to a symbol that must be
select'd, and we now remove our non-managed alloc/free functions from
outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle
Kit
with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm:
core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on this
board. After this patch was applied the Icicle kit no longer boots and
crashes immediately after OpenSBI. Between this patch and master HEAD
the following errors are found - please see attached logs for more detail:

    Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
    Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction”
and
a reset.

The last known good commit is before this commmit. I used git bisect
to confirm that 217cf656e249 (this patch) is the first bad commit.

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot
for
this
- Observe the boot failure after the above commit

Quoted 1 line

Any advise on the problem?

Quoted 9 lines

It's really strange that it bisects down to this commit, rather than something device tree related. Do you still have fdt_high=0xffffffff or
so set in the environment? It was in at least one of the logs, but I can't see for sure if it's just that the other log is from before the
commit that added the print warning about not doing that, or if it wasn't set.

Apologies for the daly in my response, I wanted to do some more debugging before getting back to you.

Thanks for the suggestion about fdt_high. We have it set in our boot scripts. I chased this down with a bisect to 9235da9446e (boot: Warn users about fdt_high=~0 usage). I have now set fdt_high to our maximum addressable value instead of ~0. This does get rid of the warning about
fdt_high in U-Boot, so that part is resolved.

However, it doesn’t fix the underlying boot issue — U-Boot still fails to boot altogether. During some bisections it often fails to apply device tree overlays and doesn’t boot the kernel - I have attached the latest crash log.

From my bisecting, the overlay breakage seems to start with the DTC/libfdt update commit (0535e46d55d...). After that, overlay application consistently fails, regardless of the fdt_high settings. As
an additional piece of information disabling MULT_DTB_FIT allows the board to boot as far as fdt error.

Quoted 3 lines

Let me know if you have any other ideas.

Thanks!

Just for some further clarity, before the DEVRES Commit:
- U-Boot boots fine with overlays disabled and fdt_high reset.
- Overlay application causes FDT errors, but base boot works.
After this DEVRES Commit (dm: core: Default to using DEVRES outside of xPL):
- U-Boot does not boot at all — no output, total crash.
- This happens regardless of overlay usage or FDT environment settings.

Regards,
Jamie

author
#24 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Quoted 113 lines · On Thu, Jan 15, 2026 at 04:59:19PM +0000, [email protected] wrote:

Hi Tom,

Quoted 110 lines · Jamie Gibbons

Hi Tom,

Quoted 74 lines · Tom Rini
Quoted 70 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 22 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel
model
where allocations are (almost always) automatically free()'d. However,
quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver
author expects that since the functions have the same name as in the
Linux Kernel they have the same behavior. In turn we then get functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and implementing free()s, rework things so that we follow expectations
by
enabling the DEVRES functionality (outside of xPL phases).

Quoted 6 lines

This turns DEVRES from a prompted symbol to a symbol that must be
select'd, and we now remove our non-managed alloc/free functions from
outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle
Kit
with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm:
core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on this
board. After this patch was applied the Icicle kit no longer boots and
crashes immediately after OpenSBI. Between this patch and master HEAD
the following errors are found - please see attached logs for more detail:

    Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
    Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction”
and
a reset.

The last known good commit is before this commmit. I used git bisect
to confirm that 217cf656e249 (this patch) is the first bad commit.

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot
for
this
- Observe the boot failure after the above commit

Quoted 1 line

Any advise on the problem?

Quoted 9 lines

It's really strange that it bisects down to this commit, rather than something device tree related. Do you still have fdt_high=0xffffffff or
so set in the environment? It was in at least one of the logs, but I can't see for sure if it's just that the other log is from before the
commit that added the print warning about not doing that, or if it wasn't set.

Apologies for the daly in my response, I wanted to do some more debugging before getting back to you.

Thanks for the suggestion about fdt_high. We have it set in our boot scripts. I chased this down with a bisect to 9235da9446e (boot: Warn users about fdt_high=~0 usage). I have now set fdt_high to our maximum addressable value instead of ~0. This does get rid of the warning about
fdt_high in U-Boot, so that part is resolved.

However, it doesn’t fix the underlying boot issue — U-Boot still fails to boot altogether. During some bisections it often fails to apply device tree overlays and doesn’t boot the kernel - I have attached the latest crash log.

From my bisecting, the overlay breakage seems to start with the DTC/libfdt update commit (0535e46d55d...). After that, overlay application consistently fails, regardless of the fdt_high settings. As
an additional piece of information disabling MULT_DTB_FIT allows the board to boot as far as fdt error.

Let me know if you have any other ideas.

Quoted 8 lines
Quoted 1 line

Thanks!

Just for some further clarity, before the DEVRES Commit:
- U-Boot boots fine with overlays disabled and fdt_high reset.
- Overlay application causes FDT errors, but base boot works.
After this DEVRES Commit (dm: core: Default to using DEVRES outside of xPL):
- U-Boot does not boot at all — no output, total crash.

So to be clear, there's just nothing on the serial port from power on? The initial logs I think confused the situation slightly. If no output, I would suggest bumping up SYS_MALLOC_F_LEN a little bit (maybe 0x2800 instead of 0x2000) and see.

Signature · 1 line
Tom
#25 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Hi Tom,

Quoted 152 lines · Tom Rini
Quoted 142 lines · On Thu, Jan 15, 2026 at 04:59:19PM +0000, [email protected] wrote:

Hi Tom,

Quoted 135 lines · Jamie Gibbons

Hi Tom,

Quoted 89 lines · Tom Rini
Quoted 85 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 29 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel
model
where allocations are (almost always) automatically free()'d.
However,
quite often we don't enable, in full U-Boot, the tracking and
free()'ing
functionality. This in turn leads to memory leaks because the
driver
author expects that since the functions have the same name as in
the
Linux Kernel they have the same behavior. In turn we then get
functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that
manually
add these calls. Rather than manually tracking allocations and
implementing free()s, rework things so that we follow expectations
by
enabling the DEVRES functionality (outside of xPL phases).

Quoted 8 lines

This turns DEVRES from a prompted symbol to a symbol that must
be
select'd, and we now remove our non-managed alloc/free functions
from
outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle
Kit
with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm:
core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on
this
board. After this patch was applied the Icicle kit no longer boots
and
crashes immediately after OpenSBI. Between this patch and master
HEAD
the following errors are found - please see attached logs for more
detail:

    Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
    Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction”
and
a reset.

The last known good commit is before this commmit. I used git bisect
to confirm that 217cf656e249 (this patch) is the first bad commit.

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot
for
this
- Observe the boot failure after the above commit

Quoted 1 line

Any advise on the problem?

Quoted 14 lines

It's really strange that it bisects down to this commit, rather than
something device tree related. Do you still have fdt_high=0xffffffff
or
so set in the environment? It was in at least one of the logs, but I
can't see for sure if it's just that the other log is from before
the
commit that added the print warning about not doing that, or if it
wasn't set.

Apologies for the daly in my response, I wanted to do some more debugging before getting back to you.

Thanks for the suggestion about fdt_high. We have it set in our boot
scripts. I chased this down with a bisect to 9235da9446e (boot:
Warn
users about fdt_high=~0 usage). I have now set fdt_high to our maximum
addressable value instead of ~0. This does get rid of the warning about
fdt_high in U-Boot, so that part is resolved.

However, it doesn’t fix the underlying boot issue — U-Boot still fails
to boot altogether. During some bisections it often fails to apply device tree overlays and doesn’t boot the kernel - I have attached the
latest crash log.

From my bisecting, the overlay breakage seems to start with the DTC/libfdt update commit (0535e46d55d...). After that, overlay application consistently fails, regardless of the fdt_high settings.
As
an additional piece of information disabling MULT_DTB_FIT allows the
board to boot as far as fdt error.

Quoted 3 lines

Let me know if you have any other ideas.

Thanks!

Quoted 7 lines

Just for some further clarity, before the DEVRES Commit:
 - U-Boot boots fine with overlays disabled and fdt_high reset.
 - Overlay application causes FDT errors, but base boot works. After this DEVRES Commit (dm: core: Default to using DEVRES outside of
xPL):
 - U-Boot does not boot at all — no output, total crash.

Quoted 6 lines

So to be clear, there's just nothing on the serial port from power on? The initial logs I think confused the situation slightly. If no output,
I would suggest bumping up SYS_MALLOC_F_LEN a little bit (maybe 0x2800 instead of 0x2000) and see.

Sorry for the confusion and thank you for your suggestion. I will attempt to clarify below.

In summary, I found three issues in mainline U-Boot between the v2026.01 tag and the master branch.

1. No boot (no output at all from U-Boot on the serial port) - introduced by 217cf656e24 dm: core: Default to using DEVRES outside of xPL - fixed by your suggestion above: s/CONFIG_SYS_MALLOC_F_LEN=0x2000/ CONFIG_SYS_MALLOC_F_LEN=0x2800 in u-boot defconfigs

2. fdt_high warning - introduced by 9235da9446e boot: Warn users about fdt_high=~0 usage - fixed by: s/setenv fdt_high 0xffffffffffffffff/setenv fdt_high 0xbfffffffin in our build systems boot scripts

3. failed on fdt_open_into for DTO, i.e. overlay application fdt error - introduced by 0535e46d55d scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47c - no fix implemented as of yet. Any suggestions on this are appreciated also.

Thank you again,
Jamie.

author
#26 lore raw

Re: [PATCH v2 2/2] dm: core: Default to using DEVRES outside of xPL

Quoted 177 lines · On Fri, Jan 16, 2026 at 01:59:21PM +0000, [email protected] wrote:

Hi Tom,

Quoted 152 lines · Tom Rini
Quoted 142 lines · On Thu, Jan 15, 2026 at 04:59:19PM +0000, [email protected] wrote:

Hi Tom,

Quoted 135 lines · Jamie Gibbons

Hi Tom,

Quoted 89 lines · Tom Rini
Quoted 85 lines · On Wed, Jan 14, 2026 at 02:33:04PM +0000, [email protected] wrote:

Hi all,

Quoted 29 lines · Tom Rini

The devm alloc functions that we have may follow the Linux kernel
model
where allocations are (almost always) automatically free()'d.
However,
quite often we don't enable, in full U-Boot, the tracking and
free()'ing
functionality. This in turn leads to memory leaks because the
driver
author expects that since the functions have the same name as in
the
Linux Kernel they have the same behavior. In turn we then get
functionally correct commits such as commit 00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that
manually
add these calls. Rather than manually tracking allocations and
implementing free()s, rework things so that we follow expectations
by
enabling the DEVRES functionality (outside of xPL phases).

Quoted 8 lines

This turns DEVRES from a prompted symbol to a symbol that must
be
select'd, and we now remove our non-managed alloc/free functions
from
outside of xPL builds.

I’ve encountered a regression on the Microchip PolarFire SoC Icicle
Kit
with mainline U-Boot.

After commit 217cf656e249 - the application of this patch (“dm:
core:
Default to using DEVRES outside of xPL”), U-Boot fails to boot on
this
board. After this patch was applied the Icicle kit no longer boots
and
crashes immediately after OpenSBI. Between this patch and master
HEAD
the following errors are found - please see attached logs for more
detail:

    Failed to reserve memory for fdt at 0xbf386210 Required FDT relocation for applying DTOs failed: 1 Could not find a valid device tree
    Device tree not found or missing FDT support ### ERROR ### Please RESET the board ###

Sometimes, I also see an “Unhandled exception: Illegal instruction”
and
a reset.

The last known good commit is before this commmit. I used git bisect
to confirm that 217cf656e249 (this patch) is the first bad commit.

Steps to reproduce:
- Build U-Boot for MPFS Icicle Kit
- Boot using HSS payload as usual - I use our build system Buildroot
for
this
- Observe the boot failure after the above commit

Quoted 1 line

Any advise on the problem?

Quoted 14 lines

It's really strange that it bisects down to this commit, rather than
something device tree related. Do you still have fdt_high=0xffffffff
or
so set in the environment? It was in at least one of the logs, but I
can't see for sure if it's just that the other log is from before
the
commit that added the print warning about not doing that, or if it
wasn't set.

Apologies for the daly in my response, I wanted to do some more debugging before getting back to you.

Thanks for the suggestion about fdt_high. We have it set in our boot
scripts. I chased this down with a bisect to 9235da9446e (boot:
Warn
users about fdt_high=~0 usage). I have now set fdt_high to our maximum
addressable value instead of ~0. This does get rid of the warning about
fdt_high in U-Boot, so that part is resolved.

However, it doesn’t fix the underlying boot issue — U-Boot still fails
to boot altogether. During some bisections it often fails to apply device tree overlays and doesn’t boot the kernel - I have attached the
latest crash log.

From my bisecting, the overlay breakage seems to start with the DTC/libfdt update commit (0535e46d55d...). After that, overlay application consistently fails, regardless of the fdt_high settings.
As
an additional piece of information disabling MULT_DTB_FIT allows the
board to boot as far as fdt error.

Quoted 3 lines

Let me know if you have any other ideas.

Thanks!

Quoted 7 lines

Just for some further clarity, before the DEVRES Commit:
 - U-Boot boots fine with overlays disabled and fdt_high reset.
 - Overlay application causes FDT errors, but base boot works. After this DEVRES Commit (dm: core: Default to using DEVRES outside of
xPL):
 - U-Boot does not boot at all — no output, total crash.

Quoted 6 lines

So to be clear, there's just nothing on the serial port from power on? The initial logs I think confused the situation slightly. If no output,
I would suggest bumping up SYS_MALLOC_F_LEN a little bit (maybe 0x2800 instead of 0x2000) and see.

Sorry for the confusion and thank you for your suggestion. I will attempt to clarify below.

In summary, I found three issues in mainline U-Boot between the v2026.01 tag and the master branch.

1. No boot (no output at all from U-Boot on the serial port) - introduced by 217cf656e24 dm: core: Default to using DEVRES outside of xPL - fixed by your suggestion above: s/CONFIG_SYS_MALLOC_F_LEN=0x2000/ CONFIG_SYS_MALLOC_F_LEN=0x2800 in u-boot defconfigs

2. fdt_high warning - introduced by 9235da9446e boot: Warn users about fdt_high=~0 usage - fixed by: s/setenv fdt_high 0xffffffffffffffff/setenv fdt_high 0xbfffffffin in our build systems boot scripts

Quoted 4 lines

3. failed on fdt_open_into for DTO, i.e. overlay application fdt error - introduced by 0535e46d55d scripts/dtc: Update to upstream version v1.7.2-35-g52f07dcca47c - no fix implemented as of yet. Any suggestions on this are appreciated also.

Ah good. For #3, can you please start a new thread, and Cc Marek, and include the full console long from power-on along with 'printenv' in there before failure? That'll help figure things out.

Signature · 1 line
Tom
author
#27 lore raw
In reply to Tom Rini
Quoted 16 lines · Tom Rini

Hey all,

As seen by a number of patches fixing memory leaks, U-Boot has a problem with developer expectations around devm_kmalloc and friends. Namely, whereas in Linux these memory allocations will be freed automatically in most cases, in U-Boot this is only true if DEVRES is enabled. Now, intentionally, in xPL phases, we do not (and do not offer as an option) enabling DEVRES. However in full U-Boot this is left either to the user, or some drivers have select'd DEVRES on their own. This inconsistency is a problem. This series goes and deals with two small issues that were shown by having all drivers that use devm_.alloc to allocate memory also select DEVRES and then we make DEVRES no longer be a prompted option and instead select'd as needed. We do not make this unconditional as it would result in growing the resulting binary on the many platforms which have no users of the devm_.alloc family of functions.

Quoted 1 line

[...]

Applied to u-boot/master, thanks!

[1/2] x86: Increase SYS_MALLOC_F_LEN to 0x1000

      commit: 284e1a00f4f28dcd6ddc8c860d22f1c8c427c5d5
[2/2] dm: core: Default to using DEVRES outside of xPL
      commit: 217cf656e249f698d390a7d8eaf255eb1a6c0230
Signature · 1 line
Tom