Enable / require DEVRES for devm_.alloc usage outside xPL
Subsystems (31)
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
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
@@ -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
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.
Signed-off-by Tom Rini <[email protected]>---
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@@ -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
PATCH 2/3 x86: Increase SYS_MALLOC_F_LEN to 0x1000
In reply to Tom RiniA 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
@@ -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
@@ -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
@@ -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
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_LENvalue of0x1000or 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
Signed-off-by Tom Rini <[email protected]>---
Cc: Bin Meng <[email protected]>--- Kconfig | 4 ++-- arch/x86/Kconfig | 3 --- configs/qemu-x86_defconfig | 1 - 3 files changed, 2 insertions(+), 6 deletions(-)
PATCH 3/3 dm: core: Default to using DEVRES outside of xPL
In reply to Tom RiniThe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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_REMOVEto 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
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_REMOVEto save code size.I'm not talking about
DM_DEVICE_REMOVEanywhere 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
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_REMOVEto save code size.I'm not talking about
DM_DEVICE_REMOVEanywhere 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
Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL
In reply to Tom RiniHi 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.
Signed-off-by Tom Rini <[email protected]>--- 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@@ -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 helpdrivers/block/Kconfig +1
-0@@ -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 devicedrivers/clk/Kconfig +1
-0@@ -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 requestdrivers/core/Kconfig +2
-1@@ -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_DEVRESdrivers/dma/ti/Kconfig +1
-0@@ -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_PSILCFGdrivers/firmware/Kconfig +1
-0@@ -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 helpdrivers/firmware/arm-ffa/Kconfig +1
-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 helpdrivers/gpio/Kconfig +3
-0@@ -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 useddrivers/i2c/muxes/Kconfig +1
-0@@ -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 todrivers/i3c/Kconfig +1
-0@@ -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@@ -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@@ -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_NANDdrivers/mtd/nand/spi/Kconfig +1
-0@@ -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 helpdrivers/mtd/spi/Kconfig +1
-0@@ -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 interfacedrivers/mux/Kconfig +1
-0@@ -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 shoulddrivers/net/Kconfig +3
-0@@ -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_MDIOdrivers/net/phy/Kconfig +2
-0@@ -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@@ -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@@ -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@@ -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 ofdrivers/pinctrl/mscc/Kconfig +1
-0@@ -2,6 +2,7 @@ config PINCTRL_MSCC bool + select DEVRES config PINCTRL_MSCC_OCELOT depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROLdrivers/pinctrl/mvebu/Kconfig +1
-0@@ -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 ondrivers/pinctrl/renesas/Kconfig +1
-0@@ -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@@ -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 useddrivers/reboot-mode/Kconfig +1
-0@@ -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 parameterdrivers/reset/Kconfig +1
-0@@ -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 somedrivers/smem/Kconfig +1
-0@@ -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 alldrivers/soc/ti/Kconfig +1
-0@@ -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@@ -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@@ -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@@ -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@@ -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@@ -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 / TIinclude/dm/devres.h +0
-0
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
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 backFix 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
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 backFix 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:
commit00e1fed93c8c3e4c9037741ea1b70a9e693a6e65Author: Francois Berder <[email protected]> Date: Tue Nov 11 11:30:19 2025 +0100firmware:
ti_sci: Fix memory leaks indevm_ti_sci_get_of_resource- Fix temp memory leak
- Free memory during error handlingSigned-off-by Francois Berder <[email protected]>
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.cdoesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, anddevm_kfreethese devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches addingdevm_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
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 backFix 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:
commit00e1fed93c8c3e4c9037741ea1b70a9e693a6e65Author: Francois Berder <[email protected]> Date: Tue Nov 11 11:30:19 2025 +0100firmware:
ti_sci: Fix memory leaks indevm_ti_sci_get_of_resource- Fix temp memory leak
- Free memory during error handlingSigned-off-by Francois Berder <[email protected]>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.cdoesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, anddevm_kfreethese devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches addingdevm_kfree()calls to devm_kmalloc()'d areas.
Quoted 2 lines
As far as I understand the
devres_release_probeshould then free the resources allocated todm_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
Michael Nazzareno Trimarchi
Reviewed-byRe: [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 backFix 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:
commit00e1fed93c8c3e4c9037741ea1b70a9e693a6e65Author: Francois Berder <[email protected]> Date: Tue Nov 11 11:30:19 2025 +0100firmware:
ti_sci: Fix memory leaks indevm_ti_sci_get_of_resource- Fix temp memory leak
- Free memory during error handlingSigned-off-by Francois Berder <[email protected]>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.cdoesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, anddevm_kfreethese devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches addingdevm_kfree()calls to devm_kmalloc()'d areas.
Quoted 7 lines
Quoted 2 lines
As far as I understand the
devres_release_probeshould then free the resources allocated todm_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
Re: [PATCH 3/3] dm: core: Default to using DEVRES outside of xPL
In reply to Tom RiniQuoted 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 backFix 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:
commit00e1fed93c8c3e4c9037741ea1b70a9e693a6e65Author: Francois Berder <[email protected]> Date: Tue Nov 11 11:30:19 2025 +0100firmware:
ti_sci: Fix memory leaks indevm_ti_sci_get_of_resource- Fix temp memory leak
- Free memory during error handlingSigned-off-by Francois Berder <[email protected]>
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.cdoesn't work the way it's documented and expected, the normal unwind path will eventually say "Ah, anddevm_kfreethese devm_kmalloc'd areas". This was part of either the discussion for that patch, or another one of Francois' patches addingdevm_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
Re: (subset) [PATCH 0/3] Enable / require DEVRES for devm_.alloc usage outside xPL
In reply to Tom RiniQuoted 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_kmallocand 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
v2 cover Enable / require DEVRES for devm_.alloc usage outside xPL
In reply to Tom RiniHey 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
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
@@ -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
@@ -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
@@ -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
PATCH v2 2/2 dm: core: Default to using DEVRES outside of xPL
In reply to Tom RiniThe 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
Reviewed-by Michael Trimarchi <[email protected]>Signed-off-by Tom Rini <[email protected]>---
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 mentioningdevm_kmallocand 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
-0stm32mp/Kconfig
indexba4694f29644..2716844b2599100644arch/arm/mach-stm32mp/Kconfig +0
-0@@ -170,6 +170,7 @@ config STM32_ECDSA_VERIFY
configSTM32MP_TAMP_NVMEM
bool "STM32 TAMP backup registers via NVMEM API" + select DEVRES
select NVMEM
default y
helpdrivers/block/Kconfig +0
-0@@ -265,6 +265,7 @@ config SYS_64BIT_LBA
config RKMTD
bool "Rockchip rkmtd virtual block device"
+ select DEVRES
selectRANDOM_UUID
help
Enable "rkmtd" class and driver to create a virtual block devicedrivers/clk/Kconfig +0
-0@@ -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 requestdrivers/core/Kconfig +0
-0@@ -197,6 +197,7 @@ config DM_DMAconfig 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 mapdrivers/core/Kconfig +0
-0@@ -271,16 +272,17 @@ config VPL_SYSCONassigning 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 viadevm_kmallocand 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()tokzalloc(),
+ This option is disabled in xPL phases and devres functions fall back
+ to non-managed variants. For example,devres_alloc()tokzalloc(),
devm_kmalloc()tokmalloc(), etc.
configDEBUG_DEVRESdrivers/dma/ti/Kconfig +0
-0@@ -5,6 +5,7 @@ if ARCH_K3config
TI_K3_NAVSS_UDMA
bool "Texas Instruments UDMA"
depends onARCH_K3
+ select DEVRES
select DMA
selectTI_K3_NAVSS_RINGACC
selectTI_K3_NAVSS_PSILCFGdrivers/firmware/Kconfig +0
-0@@ -16,6 +16,7 @@ config ARM_PSCI_FWconfig
TI_SCI_PROTOCOL
tristate "TI System Control Interface (TISCI) Message Protocol"
depends onK3_SEC_PROXY
+ select DEVRES
select FIRMWARE
selectSPL_FIRMWAREif SPL
helpdrivers/firmware/arm- renamed from drivers/firmware/arm-ffa/Kconfig +0
-0ffa/Kconfig
indexd75f8b53fd85..3706a8893059100644drivers/firmware/arm-ffa/Kconfig +0
-0@@ -6,6 +6,7 @@ config ARM_FFA_TRANSPORTselect
ARM_SMCCCif !SANDBOX
selectARM_SMCCC_FEATURESif !SANDBOX
implyCMD_ARMFFA
+ select DEVRES
selectLIB_UUID
select DEVRES
helpdrivers/gpio/Kconfig +0
-0@@ -19,6 +19,7 @@ if GPIOconfig
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 bydrivers/gpio/Kconfig +0
-0@@ -151,6 +152,7 @@ config CORTINA_GPIOconfig
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
configIPROC_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 useddrivers/i2c/muxes/Kconfig +0
-0@@ -51,6 +51,7 @@ config I2C_MUX_PCA954xconfig
I2C_MUX_GPIO
tristate "GPIO-based I2C multiplexer"
depends onI2C_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 todrivers/i3c/Kconfig +0
-0@@ -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@@ -31,6 +31,7 @@ config IMX_MU_MBOXconfig
MPFS_MBOX
bool "Enable MPFS system controller support" depends onDM_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@@ -51,6 +51,7 @@ config DM_NAND_ATMELbool "Support Atmel NAND controller with DM support" depends on
ARCH_AT91
selectATMEL_EBI
+ select DEVRES
selectSYS_NAND_SELF_INIT
implySYS_NAND_USE_FLASH_BBT
helpdrivers/mtd/nand/raw/Kconfig +0
-0@@ -74,6 +75,7 @@ config ATMEL_NAND_HWECCconfig
ATMEL_NAND_HW_PMECC
bool "Atmel Programmable Multibit ECC (PMECC)" selectATMEL_NAND_HWECC
+ select DEVRES
help
The Programmable Multibit ECC (PMECC) controller is a programmable
binaryBCH(Bose, Chaudhuri and Hocquenghem)encoder and decoder.drivers/mtd/nand/raw/Kconfig +0
-0@@ -118,6 +120,7 @@ config NAND_BRCMNANDbool "Support Broadcom NAND controller" depends on
OF_CONTROL&& DM &&DM_MTD
depends onARCH_BCMBCA||ARCH_BMIPS||TARGET_BCMNS||TARGET_BCMNS3
+ select DEVRES
selectSYS_NAND_SELF_INIT
help
Enable the driver for NAND flash on platforms using a Broadcom NANDdrivers/mtd/nand/raw/Kconfig +0
-0@@ -197,6 +200,7 @@ config SPL_NAND_LOADconfig
NAND_CADENCE
bool "Support Cadence NAND controller as a DT device" depends onOF_CONTROL&&DM_MTD&&ARCH_SOCFPGA+ select DEVRES
selectSYS_NAND_SELF_INIT
selectSPL_SYS_NAND_SELF_INIT
selectSPL_NAND_BASEdrivers/mtd/nand/raw/Kconfig +0
-0@@ -211,6 +215,7 @@ config NAND_CADENCE
configNAND_DENALI
bool
+ select DEVRES
selectSYS_NAND_SELF_INIT
selectSYS_NAND_ONFI_DETECTIONifTARGET_SOCFPGA_SOC64implyCMD_NANDdrivers/mtd/nand/spi/Kconfig +0
-0@@ -1,6 +1,7 @@menuconfig
MTD_SPI_NAND
bool "SPI NAND device Support"
depends onDM_MTD&&DM_SPI
+ select DEVRES
selectMTD_NAND_CORE
selectSPI_MEM
helpdrivers/mtd/spi/Kconfig +0
-0@@ -3,6 +3,7 @@ menu "SPI Flash Support"config
DM_SPI_FLASH
bool "Enable Driver Model for SPI flash"
depends onDM_SPI
+ select DEVRES
implySPI_FLASH
help
Enable driver model for SPI flash. This SPI flash interfacedrivers/mux/Kconfig +0
-0@@ -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 shoulddrivers/net/Kconfig +0
-0@@ -125,6 +125,7 @@ config AIROHA_ETHbool "Airoha Ethernet QDMA Driver"
depends onARCH_AIROHA
select PHYLIB
+ select DEVRES
selectDM_RESET
selectMDIO_MT7531
helpdrivers/net/Kconfig +0
-0@@ -359,6 +360,7 @@ config ETH_SANDBOX_RAW
configETH_DESIGNWARE
bool "Synopsys Designware Ethernet MAC" + select DEVRES
select PHYLIB
implyETH_DESIGNWARE_SOCFPGAifARCH_SOCFPGAhelpdrivers/net/Kconfig +0
-0@@ -555,6 +557,7 @@ config MVNETAconfig MVPP2
bool "Marvell Armada 375/7K/8K network interface support" depends onARMADA_375||ARMADA_8K
+ select DEVRES
select PHYLIB
select MVMDIO
selectDM_MDIOdrivers/net/phy/Kconfig +0
-0@@ -182,6 +182,7 @@ config PHY_MARVELL
configPHY_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
configPHY_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@@ -131,6 +131,7 @@ config PCIE_APPLEbool "Enable Apple PCIe driver"
depends onARCH_APPLE
implyPCI_INIT_R
+ select DEVRES
selectSYS_PCI_64BIT
default y
helpdrivers/pci/Kconfig +0
-0@@ -264,6 +265,7 @@ config PCI_XILINX
configPCIE_LAYERSCAPE
bool
+ select DEVRES
configPCIE_LAYERSCAPE_RC
bool "Layerscape PCIe Root Complex mode support"drivers/pci/Kconfig +0
-0@@ -361,6 +363,7 @@ config PCI_KEYSTONEconfig
PCIE_MEDIATEK
bool "MediaTek PCIe Gen2 controller"
depends onARCH_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@@ -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@@ -294,6 +294,7 @@ config PINCTRL_SANDBOXconfig
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 ofdrivers/pinctrl/mscc/Kconfig +0
-0@@ -2,6 +2,7 @@
configPINCTRL_MSCC
bool
+ select DEVRES
configPINCTRL_MSCC_OCELOT
depends onSOC_OCELOT&&PINCTRL_FULL&&OF_CONTROLdrivers/pinctrl/mvebu/Kconfig +0
-0@@ -9,6 +9,7 @@ config PINCTRL_ARMADA_38X
configPINCTRL_ARMADA_37XX
depends onARMADA_3700&&PINCTRL_FULL
+ select DEVRES
bool "Armada 37xx pin control driver"
help
Support pin multiplexing and pin configuration control ondrivers/pinctrl/renesas/Kconfig +0
-0@@ -166,6 +166,7 @@ config PINCTRL_RZG2Ldepends on PINCTRL
depends onPINCTRL_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@@ -228,6 +228,7 @@ config DM_REGULATOR_GPIOconfig
DM_REGULATOR_QCOM_RPMH
bool "Enable driver model for Qualcomm RPMh regulator" depends onDM_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 useddrivers/reboot-mode/Kconfig +0
-0@@ -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 parameterdrivers/reset/Kconfig +0
-0@@ -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 somedrivers/smem/Kconfig +0
-0@@ -16,6 +16,7 @@ config MSM_SMEMbool "Qualcomm Shared Memory Manager (SMEM)" depends on DM
depends onARCH_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 alldrivers/soc/ti/Kconfig +0
-0@@ -8,6 +8,7 @@ if SOC_TIconfig
TI_K3_NAVSS_RINGACC
bool "K3 Ring accelerator Sub System"
depends onARCH_K3
+ select DEVRES
select MISC
help
Say y here to support the K3 AM65x Ring accelerator module.drivers/spi/Kconfig +0
-0@@ -35,6 +35,7 @@ config DM_SPI
configSPI_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 memoriesdrivers/spi/Kconfig +0
-0@@ -343,6 +344,7 @@ config MT7621_SPIconfig
MTK_SNOR
bool "Mediatek SPI-NOR controller driver" depends onSPI_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@@ -1,6 +1,7 @@config
USB_CDNS3
tristate "Cadence USB3 Dual-Role Controller" depends onUSB_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@@ -1,6 +1,7 @@config
USB_DWC3
bool "DesignWare USB3 DRD Core Support" depends onUSB_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@@ -367,6 +367,7 @@ config USB_OHCI_GENERICconfig
USB_OHCI_DA8XX
bool "Support for da850 OHCI USB controller" depends onARCH_DAVINCI
+ select DEVRES
help
Enable support for the da850 USB controller.drivers/video/Kconfig +0
-0@@ -831,6 +831,7 @@ config BACKLIGHT_LM3533config
BACKLIGHT_LP855x
bool "Backlight Driver for LP855x"
depends on BACKLIGHT
+ select DEVRES
selectDM_I2C
help
Say Y to enable the backlight driver for National Semiconductor / TIinclude/dm/devres.h +0
-0@@ -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_tsize,gfp_tgfp)
{
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
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 bisectto confirm that217cf656e249(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 commitAny 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
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 that217cf656e249(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 commitAny 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 ###
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 that217cf656e249(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 commitQuoted 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 to9235da9446e(boot: Warn users about fdt_high=~0 usage). I have now setfdt_highto our maximum addressable value instead of ~0. This does get rid of the warning aboutfdt_highin 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 thefdt_highsettings. As
an additional piece of information disablingMULT_DTB_FITallows 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
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 that217cf656e249(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 commitQuoted 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 to9235da9446e(boot: Warn users about fdt_high=~0 usage). I have now setfdt_highto our maximum addressable value instead of ~0. This does get rid of the warning aboutfdt_highin 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 thefdt_highsettings. As
an additional piece of information disablingMULT_DTB_FITallows 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 andfdt_highreset.
- 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
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 that217cf656e249(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 commitQuoted 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 to9235da9446e(boot:
Warn
users about fdt_high=~0 usage). I have now setfdt_highto our maximum
addressable value instead of ~0. This does get rid of the warning aboutfdt_highin 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 thefdt_highsettings.
As
an additional piece of information disablingMULT_DTB_FITallows 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 andfdt_highreset.
- 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 upSYS_MALLOC_F_LENa little bit (maybe0x2800instead of0x2000) 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.
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 commit00e1fed93c8c("firmware:ti_sci: Fix memory leaks indevm_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
0xbf386210Required 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 that217cf656e249(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 commitQuoted 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 to9235da9446e(boot:
Warn
users about fdt_high=~0 usage). I have now setfdt_highto our maximum
addressable value instead of ~0. This does get rid of the warning aboutfdt_highin 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 thefdt_highsettings.
As
an additional piece of information disablingMULT_DTB_FITallows 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 andfdt_highreset.
- 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 upSYS_MALLOC_F_LENa little bit (maybe0x2800instead of0x2000) 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
217cf656e24dm: 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=0x2800in u-boot defconfigs2.
fdt_highwarning - introduced by9235da9446eboot: Warn users about fdt_high=~0 usage - fixed by: s/setenvfdt_high0xffffffffffffffff/setenvfdt_high0xbfffffffin in our build systems boot scripts
Quoted 4 lines
3. failed on
fdt_open_intofor DTO, i.e. overlay application fdt error - introduced by0535e46d55dscripts/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
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_kmallocand 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: 217cf656e249f698d390a7d8eaf255eb1a6c0230Signature · 1 line
Tom