mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 00/19] driver: add devm_ support
@ 2026-10-28  9:14 Ahmad Fatoum
  2026-10-28  9:14 ` [PATCH 01/19] commands: devunbind: refuse to unbind devices that were never bound Ahmad Fatoum
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Ahmad Fatoum @ 2026-10-28  9:14 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We currently have only devm_ macro fakery that leaks resources on device
removal. This is flagged by static analysis and requires modifications
to ported kernel code that uses devres-managed actions.

Implement destructor support into talloc and use it implement a subset
of the Linux devm functionality. 

How devm_ allocated device resources are freed is a bit different from
Linux:

- Runtime unbounding of a device driver or removal of a device
  frees _all_ device resources

- Boot time invocation of the remove callback is followed by running
  _only_ the destructors. Allocations are leaked as the kernel will
  reclaim all memory anyway.

Ahmad Fatoum (19):
  commands: devunbind: refuse to unbind devices that were never bound
  commands: devunbind: don't poison the active list entry
  talloc: remove unused talloc_steal() and talloc_steal_children()
  talloc: free children in a loop
  talloc: add support for destructors
  test: self: talloc: add destructor tests
  talloc: add talloc_run_destructors()
  mfd: pca9450: don't free device-managed memory in probe error path
  video: backlight-pwm: allocate brightness levels with devm_kcalloc
  driver: implement devm_ allocation helpers on top of talloc
  devres: Provide kmalloc_obj*-style API for devm_kmalloc
  memory: atmel-ebi: use generic devm_kzalloc()
  driver: add devm_add_action()
  test: self: add devm_ selftest
  driver: add devm_request_mem_resource()
  driver: make dev_platform_ioremap_resource() device-managed
  treewide: rename dev_platform_ioremap_resource() to
    devm_platform_ioremap_resource()
  driver: make dev_platform_get_and_ioremap_resource() device-managed
  serial: stm32: request the registers with devm_request_mem_resource()

 commands/devunbind.c                          |  11 +-
 drivers/base/Makefile                         |   1 +
 drivers/base/devres.c                         | 259 ++++++++++++++
 drivers/base/driver.c                         |  61 ++--
 drivers/hw_random/atmel-rng.c                 |   2 +-
 drivers/hw_random/bcm2835-rng.c               |   2 +-
 drivers/hw_random/iproc-rng200.c              |   2 +-
 drivers/hw_random/omap-rng.c                  |   2 +-
 drivers/hw_random/timeriomem-rng.c            |   2 +-
 drivers/memory/atmel-ebi.c                    |   6 +-
 drivers/mfd/atmel-flexcom.c                   |   2 +-
 drivers/mfd/pca9450.c                         |  20 +-
 .../phy/rockchip/phy-rockchip-inno-dsidphy.c  |   2 +-
 drivers/phy/rockchip/phy-rockchip-usbdp.c     |   2 +-
 drivers/pmdomain/imx/imx8mp-blk-ctrl.c        |   2 +-
 drivers/pmdomain/imx/imx93-blk-ctrl.c         |   2 +-
 drivers/pmdomain/imx/imx93-pd.c               |   2 +-
 drivers/pwm/pwm-imx-tpm.c                     |   2 +-
 drivers/pwm/pwm-rockchip.c                    |   2 +-
 drivers/serial/serial_stm32.c                 |   6 +-
 drivers/spi/spi-fsl-qspi.c                    |   2 +-
 drivers/usb/dwc3/dwc3-imx8mp.c                |   2 +-
 drivers/video/backlight-pwm.c                 |   6 +-
 drivers/video/rockchip/dw-mipi-dsi-rockchip.c |   2 +-
 include/device.h                              |   3 +
 include/driver.h                              |  27 +-
 include/linux/device.h                        | 152 ++++++--
 include/talloc.h                              |   5 +-
 lib/talloc.c                                  | 205 ++++++-----
 test/self/Kconfig                             |   6 +
 test/self/Makefile                            |   1 +
 test/self/devres.c                            | 327 ++++++++++++++++++
 test/self/talloc.c                            | 207 +++++++++++
 33 files changed, 1148 insertions(+), 187 deletions(-)
 create mode 100644 drivers/base/devres.c
 create mode 100644 test/self/devres.c

-- 
2.47.3




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-10-28  9:52 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28  9:14 [PATCH 00/19] driver: add devm_ support Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 01/19] commands: devunbind: refuse to unbind devices that were never bound Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 02/19] commands: devunbind: don't poison the active list entry Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 03/19] talloc: remove unused talloc_steal() and talloc_steal_children() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 04/19] talloc: free children in a loop Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 05/19] talloc: add support for destructors Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 06/19] test: self: talloc: add destructor tests Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 07/19] talloc: add talloc_run_destructors() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 08/19] mfd: pca9450: don't free device-managed memory in probe error path Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 09/19] video: backlight-pwm: allocate brightness levels with devm_kcalloc Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 10/19] driver: implement devm_ allocation helpers on top of talloc Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 11/19] devres: Provide kmalloc_obj*-style API for devm_kmalloc Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 12/19] memory: atmel-ebi: use generic devm_kzalloc() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 13/19] driver: add devm_add_action() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 14/19] test: self: add devm_ selftest Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 15/19] driver: add devm_request_mem_resource() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 16/19] driver: make dev_platform_ioremap_resource() device-managed Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 17/19] treewide: rename dev_platform_ioremap_resource() to devm_platform_ioremap_resource() Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 18/19] driver: make dev_platform_get_and_ioremap_resource() device-managed Ahmad Fatoum
2026-10-28  9:14 ` [PATCH 19/19] serial: stm32: request the registers with devm_request_mem_resource() Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox