dm: core: Default to using DEVRES outside of xPL
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 00e1fed93c ("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>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
menuconfig I3C
|
||||
tristate "I3C support"
|
||||
select I2C
|
||||
select DEVRES
|
||||
help
|
||||
I3C is a serial protocol standardized by the MIPI alliance.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -4,6 +4,7 @@ menu "PHY Subsystem"
|
||||
config PHY
|
||||
bool "PHY Core"
|
||||
depends on DM
|
||||
select DEVRES
|
||||
help
|
||||
PHY support.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
config PINCTRL_MSCC
|
||||
bool
|
||||
select DEVRES
|
||||
|
||||
config PINCTRL_MSCC_OCELOT
|
||||
depends on SOC_OCELOT && PINCTRL_FULL && OF_CONTROL
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user