[PATCH net v2 00/14] net: pse-pd: assorted lifetime and error-path fixes
From: Carlo Szelinsky
Date: Tue Oct 20 2026 - 13:22:30 EST
Fixes for the PSE core and the pd692x0 driver, found while working on
the PSE controller teardown. Most of them are about what happens when a
controller unbinds or fails to register.
1 The kfifo is too small: podl-pse-regulator and any controller with
0 or 1 lines cannot register.
2 Removes two checks that can never be true. Not a fix; it makes 3
smaller.
3 A module reference leaks when reading the port state fails.
4 A failed IRQ request stays in pcdev->irq, so unregister disables a
line another device may own.
5 The notification worker can read a PHY that was already freed.
6 Setting a power limit checks the PI state without the lock.
7 A power domain shared by two controllers is freed when the one that
created it unbinds.
8 Unregister frees the PI array before it stops the IRQ handler. No
in-tree driver hits this; 10 to 12 build on the new order.
9 Unregister frees the PI array while a lookup can still find the
controller.
10 The PI regulators outlive the PI array, the PSE core can still
power a PI while the controller goes away, and a powered PI keeps
its budget.
11 A failed registration leaks the kfifo and leaves power domains with
a stale supply handle.
12 A shared power domain's supply handle goes stale when the controller
that created it unbinds.
13 pd692x0 leaks its manager power budget when probe fails.
14 pd692x0 crashes on a manager supply that is not resolved yet.
Some patches need earlier ones: 7 needs the locked check from 6, 10 to
12 build on 7 to 9, and 14 relies on 13 to give back a budget that was
already reserved.
Testing: every patch builds on its own with W=1 and is checkpatch
clean. 1, 5, 7, 10, 11 and 12 were tested in QEMU (arm64, KASAN,
lockdep, kmemleak) with test-only fake PSE controllers: without the
patch, the failure in its commit message shows up; with the whole
series, the tests are clean, except for the older lockdep report
below. The other patches were found by code inspection and are
build-tested only.
Ross Cawston's "net: pse-pd: don't enable a PI again while disabling
it" [3] applies on top of this series without conflicts. The tests also
hit two older bugs that this series does not fix:
- With the static strategy, turning off a PI to make room for a
waiting one retries the waiting PI from inside its own allocation,
which recurses until the kernel stack overflows. [3] removes that
retry.
- pse_isr(), setting a power limit and unregister hold pcdev->lock
and then take the supply's regulator lock, while regulator_enable()
on a PI takes them the other way round. Lockdep reports it when the
supply lock is contended.
Older problems that reviews of this series found, not fixed here:
- A pse_control held by a PHY can outlive its controller. The PSE
notifier series for net-next fixes this.
- Setting a power limit changes the budget and the hardware limit
under two separate locks, so pse_isr() can run in between.
- On tps23881, pse_controller_unregister() calls disable_irq() after
devres has already freed the IRQ.
- A PI waiting for budget can get budget reserved by a power limit
change; that budget is not freed when the PI is powered later.
- The PI regulators are visible before their power domain is set. A
PI enabled in that short time skips the budget check.
Changes in v2:
- 2 is new; 3 now only fixes the remaining error path (Kory).
- 5: the worker comment says why a shared PI is safe (Sashiko).
- 6: kernel-doc of the return value fixed (Sashiko, Kory).
- 8: the message no longer claims bugs that 5 and 7 made impossible
or that no in-tree driver can hit; Fixes: tag dropped.
- 8 and 9 are patches 1 and 3 of [1]. 9 now takes the controller off
the list before the worker drain and the power domain flush, as [2]
1/4 did. Patch 2 of [1] is replaced by 10, which keeps the PI array
until the PI regulators are gone, lets the core power no PI after
unregister starts, and switches off the PIs that hold budget.
- 11 is patch 2 of the PSE core fixes for net-next [2], moved here.
- 12 is new; v1 listed this bug as not fixed. The domain no longer
has a supply handle of its own; each PI uses its regulator's handle.
- The si3474 patch and the power limit overflow fix move to net-next.
- Collected Reviewed-by tags; each patch says if it was triggered.
- v1: https://lore.kernel.org/netdev/20261018082314.48950-1-github@xxxxxxxxxxxx/
[1] https://lore.kernel.org/netdev/20260813200653.980170-1-github@xxxxxxxxxxxx/
[2] https://lore.kernel.org/netdev/20261018081853.47484-1-github@xxxxxxxxxxxx/
[3] https://lore.kernel.org/netdev/20261018182005.1193-1-ross@xxxxxxx/
Carlo Szelinsky (14):
net: pse-pd: size the notification kfifo after defaulting nr_lines
net: pse-pd: remove dead pi_get_admin_state() checks
net: pse-pd: fix module refcount leak in pse_control_get_internal()
net: pse-pd: do not keep a failed IRQ in pcdev->irq
net: pse-pd: do not reach a freed PHY from the notification worker
net: pse-pd: check the PI state under the lock when setting a power
limit
net: pse-pd: do not tie a shared power domain to its creator's devres
net: pse-pd: stop async event sources before freeing PI data in
unregister
net: pse-pd: unregister from the controller list before freeing PI
data
net: pse-pd: keep the PI data until the PI regulators are gone
net: pse-pd: unwind allocations when controller registration fails
net: pse-pd: use each PI's own supply handle for the power budget
net: pse-pd: pd692x0: release the manager power budget through devres
net: pse-pd: pd692x0: defer probe while a manager supply is unresolved
drivers/net/pse-pd/pd692x0.c | 31 +++-
drivers/net/pse-pd/pse_core.c | 319 ++++++++++++++++++++++++----------
include/linux/pse-pd/pse.h | 5 +
3 files changed, 255 insertions(+), 100 deletions(-)
base-commit: 78731b46967e3e7102b5cd5062bef185f3404b5c
--
2.43.0