The devm alloc functions that we have may follow the Linux kernel model
where allocations are (almost always) automatically free()'d. However,
quite often we don't enable, in full U-Boot, the tracking and free()'ing
functionality. This in turn leads to memory leaks because the driver
author expects that since the functions have the same name as in the
Linux Kernel they have the same behavior. In turn we then get
functionally correct commits such as commit
00e1fed93c8c ("firmware:
ti_sci: Fix memory leaks in devm_ti_sci_get_of_resource") that manually
add these calls. Rather than manually tracking allocations and
implementing free()s, rework things so that we follow expectations by
enabling the DEVRES functionality (outside of xPL phases).
This turns DEVRES from a prompted symbol to a symbol that must be
select'd, and we now remove our non-managed alloc/free functions from
outside of xPL builds.
Reviewed-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
config STM32MP_TAMP_NVMEM
bool "STM32 TAMP backup registers via NVMEM API"
+ select DEVRES
select NVMEM
default y
help
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
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
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
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
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
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
select ARM_SMCCC if !SANDBOX
select ARM_SMCCC_FEATURES if !SANDBOX
imply CMD_ARMFFA
+ select DEVRES
select LIB_UUID
select DEVRES
help
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
config DWAPB_GPIO
bool "DWAPB GPIO driver"
depends on DM && DM_GPIO
+ select DEVRES
help
Support for the Designware APB GPIO driver.
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
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
menuconfig I3C
tristate "I3C support"
select I2C
+ select DEVRES
help
I3C is a serial protocol standardized by the MIPI alliance.
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.
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
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.
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
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
config NAND_DENALI
bool
+ select DEVRES
select SYS_NAND_SELF_INIT
select SYS_NAND_ONFI_DETECTION if TARGET_SOCFPGA_SOC64
imply CMD_NAND
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
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
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
bool "Airoha Ethernet QDMA Driver"
depends on ARCH_AIROHA
select PHYLIB
+ select DEVRES
select DM_RESET
select MDIO_MT7531
help
config ETH_DESIGNWARE
bool "Synopsys Designware Ethernet MAC"
+ select DEVRES
select PHYLIB
imply ETH_DESIGNWARE_SOCFPGA if ARCH_SOCFPGA
help
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
config PHY_MARVELL_10G
bool "Marvell Alaska 10Gbit PHYs"
+ select DEVRES
help
Support for the Marvell Alaska MV88X3310 and compatible PHYs.
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.
bool "Enable Apple PCIe driver"
depends on ARCH_APPLE
imply PCI_INIT_R
+ select DEVRES
select SYS_PCI_64BIT
default y
help
config PCIE_LAYERSCAPE
bool
+ select DEVRES
config PCIE_LAYERSCAPE_RC
bool "Layerscape PCIe Root Complex mode support"
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.
config PHY
bool "PHY Core"
depends on DM
+ select DEVRES
help
PHY support.
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
config PINCTRL_MSCC
bool
+ select DEVRES
config PINCTRL_MSCC_OCELOT
depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
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
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.
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
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
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
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
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.
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
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.
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.
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.
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.
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
/* 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)
{