[PATCH v2 1/2] accel/rocket: release the shared device's devres on teardown
Heiko Stübner
heiko at sntech.de
Wed Nov 4 02:16:37 PST 2026
Am Freitag, 31. Juli 2026, 08:49:32 Mitteleuropäische Normalzeit schrieb Igor Paunovic:
> rocket_device_init() attaches its allocations to the shared "rknn"
> platform device via devres: devm_drm_dev_alloc(), devm_kcalloc() for
> the cores array and devm_mutex_init(). That device is registered at
> module init, never binds to a driver, and is only unregistered at
> module exit - so its devres list is not released for as long as the
> module is loaded.
>
> rocket_device_fini() only calls drm_dev_unregister(): it does not run
> the drm_dev_put() devres action or free any of the other entries.
> Every fini/re-init cycle therefore leaks the previous rocket_device
> (with its embedded drm_device and all drmm state, including the accel
> minor number), the cores array and the mutex devres node. The cycle is
> easy to trigger: unbind the last bound core and bind one again, or
> fail the first core's probe (-EPROBE_DEFER retries included).
>
> Observable symptom, RK3588 (Orange Pi 5 Plus): each unbind/rebind
> cycle of all three cores moves the accel node forward -
> /dev/accel/accel0 comes back as accel1, then accel2 - because every
> leaked drm_device keeps its minor pinned.
>
> Wrap the initialization in a devres group and release exactly that
> group wherever the device is torn down: on the rocket_device_init()
> error path, when the first core's rocket_core_init() fails, and when
> the last core is removed. Each fini now frees what the matching init
> allocated, and the accel minor is reusable again.
>
> Fixes: ed98261b4168 ("accel/rocket: Add a new driver for Rockchip's NPU")
> Signed-off-by: Igor Paunovic <royalnet026 at gmail.com>
not to self: patch 2 became part of the dvfs series
this one (patch1) still seems relevant
More information about the Linux-rockchip
mailing list