Re: [PATCH net-next v2 0/9] dpll: do not serialize driver callbacks under global dpll_lock

From: Ivan Vecera

Date: Thu Nov 26 2026 - 07:31:20 EST


On 11/26/26 10:15, David Laight wrote:
On Wed, 11 Nov 2026 17:40:11 +0100
Ivan Vecera <ivecera@xxxxxxxxxx> wrote:

dpll_lock protects topology and object lifetime, but it also serializes
all driver callbacks in the system, so one slow device stalls every other
DPLL device, whichever driver it belongs to. mlx5 callbacks issue firmware
commands with a 60 s default timeout, and zl3073x callbacks can wait
seconds on a driver lock held across ToD writes and phase steps.

Make dpll_lock an rwsem for topology and lifetime and add a mutex per
domain for callbacks. A domain is all objects created with one (module,
clock_id), in practice one chip or card, so channels of one chip stay
serialized as drivers expect, and they still block each other. Device
callbacks run under the domain of the device, pin callbacks under the
domain of the pin, whichever driver registered them. Only one domain lock
is ever held, so domains have no lock order. A lock per device would not
work, because pins are N:M with devices and callbacks notify sibling
channels.

The driver API does not change, but a callback can now notify only
objects of its own domain. Patch 1 changes the one in-tree callback that
does not follow this.

Registrations across domains exist in the tree only on E825, where ice
registers fwnode pins of an external DPLL with its TXC and TSPLL DPLLs.
These callbacks are no longer serialized with TXC and TSPLL, they rely on
pf->dplls.lock, and requests about these pins wait while the external
DPLL is busy. Intel folks, please check that this is fine.

Isn't the big problem with callbacks handling deregistration?
With a global lock there isn't a problem.
But as soon as you do anything else you have to have very explicit
rules to safely deregister a callback without either a UAF or an ABBA
locking issue.

I don't see this being mentioned.

David
The cover only says that dpll_lock keeps protecting the object
lifetime, the details are in patches 4 and 9.

All unregister functions take dpll_lock for write. Netlink requests,
dumps and notifications hold it for read for their whole duration,
including the callbacks. So dpll_device_unregister(),
dpll_pin_unregister() and dpll_pin_on_pin_unregister() wait until the
running callbacks finish, and no new one can start, because objects
are looked up under the read lock. Once they return, the ops and the
private data of that registration are not used anymore. This is the
same as posix_clock_unregister() taking the rwsem of the clock for
write. A KUnit test in patch 5 checks that a function taking dpll_lock
for write waits for a running callback.

For ABBA the rules are the same as with the mutex today: a driver must
not call a function that takes dpll_lock, including the unregister
functions, while holding a lock that its callbacks take, and a
callback must not call one at all. Patch 9 documents both, and lockdep
reports a violation.

Thanks,
Ivan